astroboy has asked for the wisdom of the Perl Monks concerning the following question:
I have a web page which shows a list of images. Users can click on a link next to each image to rotate them either left or right. The page is refreshed and the images re-displayed
The problem is, the images are being cached, so the previous orientation is being shown. I have tried setting the headers using CGI::Application as following (slightly modified from overkill anti-caching CGI headers):
# Set a last-modified date a little in the future to handle # local workstation times being slightly out. Is that valid? my $date = DateCalc('today', '+ 5 minutes'); $date = Date_ConvTZ($date, "", "GMT"); $self->header_add( -expires => 'Sat, 26 Jul 1997 05:00:00 GMT', -Last_Modified => UnixDate($date, '%a, %d %b %Y %H:%M:%S GMT') +, # HTTP/1.0 -Pragma => 'no-cache', # HTTP/1.1 -Cache_Control => join(', ', qw( no-store no-cache must-revalidate proxy-revalidate post-check=0 pre-check=0 max-age=0 s-maxage=0 )), );
An example of the produced header:
Date: Tue, 27 Mar 2007 03:52:20 GMT Server: Apache/1.3.34 (Unix) mod_fastcgi/2.4.2 PHP/5.0.5 Expires: Sat, 26 Jul 1997 05:00:00 GMT Pragma: no-cache Last-Modified: Tue, 27 Mar 2007 03:52:20 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre- +check=0 Keep-Alive: timeout=15, max=89 Connection: Keep-Alive Content-Type: text/html; charset=utf-8 Transfer-Encoding: chunked 200 OK
This seems to work intermittently in Firefox on both Windows and Linux, and slightly less often in MSIE v6. Any ideas appreciated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Slightly OT: Stop caching images
by grinder (Bishop) on Mar 27, 2007 at 11:27 UTC | |
by astroboy (Chaplain) on Mar 27, 2007 at 11:49 UTC | |
|
Re: Slightly OT: Stop caching images
by hangon (Deacon) on Mar 27, 2007 at 09:54 UTC | |
by astroboy (Chaplain) on Mar 27, 2007 at 11:55 UTC | |
|
Re: Slightly OT: Stop caching images
by almut (Canon) on Mar 27, 2007 at 11:37 UTC | |
by astroboy (Chaplain) on Mar 27, 2007 at 11:47 UTC | |
by erroneousBollock (Curate) on Mar 28, 2007 at 03:07 UTC | |
by astroboy (Chaplain) on Mar 28, 2007 at 04:43 UTC | |
by erroneousBollock (Curate) on Mar 29, 2007 at 14:10 UTC | |
|
Re: Slightly OT: Stop caching images
by ikegami (Patriarch) on Mar 28, 2007 at 05:10 UTC |