Description: | This is really more of a HTTP- than Perl-related post; the following snippet emits all of the currently specified HTTP headers that may affect caching, with values set to coerce clients into not caching the document in question. It’s useful for debugging as well as generated pages that actually are very dynamic, but shouldn’t be used blindly for everything – caching is there for a reason. (I’m posting this here mainly so as to have a node to refer people to as needed.) Update 2006-01-12: added private and max-age=0 to the Cache-Control header. |
use CGI qw(:standard); use POSIX qw(strftime); print header( # date in the past -expires => 'Sat, 26 Jul 1997 05:00:00 GMT', # always modified -Last_Modified => strftime('%a, %d %b %Y %H:%M:%S GMT', gmtime), # HTTP/1.0 -Pragma => 'no-cache', # HTTP/1.1 + IE-specific (pre|post)-check -Cache_Control => join(', ', qw( private no-cache no-store must-revalidate max-age=0 pre-check=0 post-check=0 )), );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: overkill anti-caching CGI headers
by webratta (Sexton) on Mar 05, 2003 at 17:36 UTC | |
Re: overkill anti-caching CGI headers
by cleverett (Friar) on Jul 23, 2003 at 05:42 UTC | |
Re: overkill anti-caching CGI headers
by davebaker (Pilgrim) on Jun 18, 2009 at 15:53 UTC | |
by oalders (Initiate) on Aug 28, 2009 at 17:09 UTC |