With a timer in my gwt application i'm timely refreshing an image that
is server side generated by a JFreechart Servlet
response.setContentType("image/png");
response.addHeader("Pragma" , "no-cache");
response.addIntHeader("Expires" , 0);
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart,
300,
250);
On the client side i do somethign like this in a Timer loop:
setSumVote(sum);
Image chart = new Image("charts?
type=overview");
chart.setSize("300px", "250px");
votesGrid.setWidget(1 ,2 , chart);
votesGrid.getFlexCellFormatter().setRowSpan(0,2, 5);
HorizontalPanel layout = new
HorizontalPanel();
layout.add(votesGrid);
layout.add(chart);
RootPanel.get("votes").clear();
RootPanel.get("votes").add(layout);
What i don't understand is why the Image is not displayed with the new
data than move on server side.
FYI: when i clear the cache file of the browser the image is refreshed
with the new data!
So i decide to add headers :
response.addHeader("Pragma" , "no-cache");
response.addIntHeader("Expires" , 0);
But this has no effect :( the image is stored again in the browser
cache directory. It that the problem i suppose
Do the header work for image MIME type ?
I really do pass on server side generation timely and with good data
values , in debugging mode !!!!
Any idea ?
Thank you by advance.
Luciano
I wrote a small sample trying to reproduce your issue and I could
verify exactly what you witnessed. The strange thing is with Firefox
that when you right-click on the image (View image) and then view the
new page's properties, the browser suddenly changes it's mind about
the 'cacheability' of that image. Searching the web I found endless
discussions about what may be the possible causes and remedies
(apparently not only FF nor GWT users alone have that problem!) and no
matter what headers I tried I could get FF to reload that image.
What did though work for me is append a dummy parameter like this:
Timer t = new Timer(){
public void run() {
image.setUrl("images/pic1.jpg?param="+(counter++));
}
};
t.scheduleRepeating(500);
which apparently is considered as a 'new' url and as such not in the
cache.
Regards
g.
first of all may thanks to gave me a response.
After investigations, i've found many post on the net about the
behavior i have encountered :)
but none give a clear solution except maybe the post on the
TheServerSide.com.
The set of headers they propose works perfectly with IE but not for
FF :) for once IE is better thant FF, The browser world is upside
down :)
At the end I've done for continuing my way the workaround you have
proposed :) but this solution will fill the cache area of the users :
(
They are others solutions that consist to generate temp chart on the
server side and after user view they are mark for deletion as a
garbage collector would do it.
Anyway. this problem should be fix simply with the HTTP headers but i
don't know what is the combinations for doing it working on FF and IE
at least.
for those who need help in same area :
response.setHeader("cache-control", "no-cache, no-store,must-
revalidate"); // HTTP 1.1
this header set work nicely for IE but not for FF :(
Indeed thank you very much for your response and the hard work you
have done to reproduce the enviromement !!!
Hoping a contributor could give us THE solution :)
Luciano,
--
http://www.gwtwindowmanager.org
On Mar 4, 9:08 pm, "georgeuoa" <g.georgovassi...@gmail.com> wrote:
Very interessing article !!!!! i will revoiew my design considering
this articles sweet advises :)
BTW i think this recipe no fix the cache problem ! ?
Regards.
Luciano,
--
http://www.gwtwindowmanager.org
On Mar 4, 9:42 pm, "dgirard" <didier.gir...@gmail.com> wrote:
> Here is an article about integrating JFreeChart and GWT :http://www.jfree.org/phpBB2/viewtopic.php?t=19080&sid=f627bee2b70...
Hi dgirad,
I've found a tiny project that use GWT/JFreeChart but when i look my
browser temporary folder i see the chart in cache but the chart seems
moving in realtime so i suppose unique url are generated to by pass
the cache process ? http://www.pokercontrolcenter.com
On Mar 4, 9:42 pm, "dgirard" <didier.gir...@gmail.com> wrote:
> Here is an article about integrating JFreeChart and GWT : http://www.jfree.org/phpBB2/viewtopic.php?t=19080&sid=f627bee2b70...
Just hope that a user that has set a browser cache size with 200mo by
mistake will not see his box going slowdown by seeing is directory
cache to fill with many has been charts.
One of my project use a lot of JFreeChart so it is really important
for me to have the best approach concerning this integration
Indeed the method you have post works perfectly.
Thank you George.
Luciano.
--
http://www.gwtwindowmanager.org
On Mar 5, 11:46 am, "George Georgovassilis"
<g.georgovassi...@gmail.com> wrote:
> Do you have some constraint that does not allow you to use the unique url
> approach? You mentioned that you were concerned about the browser cache
> filling up with images... I wouldn't worry (although is somehow presumptuous
> and may stem more from ignorance than wisdom) too much about this. Even if
> the browser has to reload that image frequently, you should be more
> concerned about the network traffic than the cache filling up (which is
> tended by the browser anyway).
>
> Am I missing something here?
>
> On 3/5/07, Luciano Broussal <luciano.brous...@gmail.com> wrote:
>
>
>
> > Hi dgirad,
>
> > I've found a tiny project that use GWT/JFreeChart but when i look my
> > browser temporary folder i see the chart in cache but the chart seems
> > moving in realtime so i suppose unique url are generated to by pass
> > the cache process ?http://www.pokercontrolcenter.com
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "max-age=0");
see:
http://forum.java.sun.com/thread.jspa?forumID=45&threadID=233446
G>
On Mar 5, 7:59 am, "Luciano Broussal" <luciano.brous...@gmail.com>
wrote:
> No pb George,
>
> Just hope that a user that has set a browser cache size with 200mo by
> mistake will not see his box going slowdown by seeing is directory
> cache to fill with many has been charts.
>
> One of my project use a lot of JFreeChart so it is really important
> for me to have the best approach concerning this integration
>
> Indeed the method you have post works perfectly.
>
> Thank you George.
>
> Luciano.
> --http://www.gwtwindowmanager.org
If someone's somehow decided to appropriate their entire harddrive as
a web cache, then their system will be crashing forthwith whether or
not you persist in solving this problem the hard way.
Seriously. Use the unique URL approach. It works. Everything else
doesn't.
On Mar 5, 11:59 am, "Luciano Broussal" <luciano.brous...@gmail.com>
wrote:
> No pb George,
>
> Just hope that a user that has set a browser cache size with 200mo by
> mistake will not see his box going slowdown by seeing is directory
> cache to fill with many has been charts.
>
> One of my project use a lot of JFreeChart so it is really important
> for me to have the best approach concerning this integration
>
> Indeed the method you have post works perfectly.
>
> Thank you George.
>
> Luciano.
> --http://www.gwtwindowmanager.org
Thank you for your post but please keep cool.
If i remember well Dan from The Google Team has already congratulate
you for good technicals posts but ask you also to be bit more cool :)
No worries.
Thank you again and continue contributing for the GWT community like
you do!!
Regards.
Luciano
--
http://www.gwtwindowmanager.org
Work like a charm!!!
Indeed, thank you to all of you!!!
Luciano
--
http://www.gwtwindoamanager.org
I wrote a test that looks about like this:
Timer t = new Timer(){
public void run() {
panel.remove(image);
image = new Image("images/pic1.jpg");
panel.add(image);
}
};
t.scheduleRepeating(5000);
And it loads the image only once. Variations like keeping the same
image and just setting the url (image.setUrl(...) ) don't work either
(we're always talking about FF 2.0, right?). Are you using only the
headers Chiraz mentioned or do you have another ace up in your sleeve?
Image('static url') != Image ('server-service-url') that give response
with a specialized stream and http headers.
Regards.
Luciano
--
http://gwtwindowmanager.org
So, what are you doing then which I'm doing wrong?
On Mar 6, 11:03 pm, "Luciano Broussal" <luciano.brous...@gmail.com>
wrote:
> right for FF2.
> Your test case can't work
> you make a call to static image which is completly different from
> asking a stream that give response with specialized headers!
>
> Image('static url') != Image ('server-service-url') that give response
> with a specialized stream and http headers.
>
> Regards.
>
> Luciano
> --http://gwtwindowmanager.org
By combining both approaches you force non-compliant clients to use
fresh copies of your charts with the unique URL and the header keeps
the conformant clients from filling their cache with your charts.
For more reading, here's a pretty good caching tutorial:
http://www.mnot.net/cache_docs/
One of Luciano's issues was that he didn't want to fill a user's
browser cache, using the Cache-Control header should prevent that for
clients that respect the header along with causing the browser to
execute a new request for the resource every time. Adding a uniqueness
factor to the URL should make every client (even non-compliant ones)
execute a new request when fetching the chart.
On Mar 7, 10:30 am, "George Georgovassilis"
I don't think that filling up the browser cache is an issue, browsers
take good care of their cache (as far as I know at least) and, unless
we're talking about an intranet application, one should be worried more
about the network traffic (after all, you have somehow to get that data
first to the user over the wire) than filling up the cache.
BR
G.
[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html
I've combined your solutions to solve my problem.
Regards.
Luciano
--
http://groups.google.com/group/gwt-window-manager
http://www.gwtwindowmanager.org
On Mar 8, 5:48 pm, "George Georgovassilis"