[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]
    Search the FAQ Archives

Single Page

Top Document: FAQ: Frequently Asked Questions about CGI Programming
Previous Document: 3.20 How can I stop my CGI script reading and writing files as "nobody"?
Next Document: 3.22 How can I control the default filename when downloading a file via CGI?


3.21 How can I prevent my CGI results being cached by the browser?



Firstly, we need to debunk a myth.  People asking this question usually
add that they tried "Pragma: no-cache".  Whilst this is not actively
wrong, there is no requirement on browsers to take any notice of it,
and most of them don't.

The "Pragma: no-cache" header (now superseded by HTTP/1.1 Cache-Control)
is a directive to proxies.  The browser sends it with an HTTP request
to indicate that it wants the request to be dealt with by the original
server and will not accept a proxy's cached document (e.g. when you
use a reload button).  The server may send it to tell a proxy not to
cache the document.

Having said all that, a practical hack to get round cacheing is
to use a different URL for your CGI script each time it's called.
This can easily be accomplished by adding a unique identifier such
as current time in the QUERY_STRING or PATH_INFO.  The browser will
see a different URL, but the script can just ignore it.  Note that
this can be very inefficient, and should be avoided where possible.




Top Document: FAQ: Frequently Asked Questions about CGI Programming
Previous Document: 3.20 How can I stop my CGI script reading and writing files as "nobody"?
Next Document: 3.22 How can I control the default filename when downloading a file via CGI?

Single Page


[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
Nick Kew <nick@webthing.com>

Last Update December 05 2008 @ 00:13 AM

© 2008 FAQS.ORG. All rights reserved.