Controlling Browser Cache

Post Reply
source1Tamer
Posts: 91
Joined: Tue Nov 13, 2001 3:49 pm

Controlling Browser Cache

Post by source1Tamer »

Hi guys,
How do I control the browser cache so when the user hit the Back button, he will get "Web Page Expired" message or expired contents? I cannot use any client code.

thanks,
Tamer
User avatar
Kai
Site Admin
Posts: 1272
Joined: Tue Apr 25, 2000 1:27 pm

Controlling Browser Cache

Post by Kai »

This is more of an HTTP question; you'd send headers like these:

Pragma: no-cache
Cache-Control: no-cache
Expires: 0

to tell the browser not to cache the page. In Vortex you would send these headers with the <header> function, making sure to do so before any output is printed:

<header NAME="Pragma" VALUE="no-cache">
<header NAME="Cache-Control" VALUE="no-cache">

Note that the browser likely won't say "Page expired" but will attempt to reload the page. Note also that that behavior of some browsers varies; some (like Netscape) will often cache an image regardless of these fields; some (like MSIE 4.0) have been known to lose the Content-Type of the document when these headers are sent.

The only guaranteed way we've found to get the browser to re-load pages, especially images, is to make the URL of each unique, eg. with a counter in the URL.
source1Tamer
Posts: 91
Joined: Tue Nov 13, 2001 3:49 pm

Controlling Browser Cache

Post by source1Tamer »

Thanks Kai,
I've added the 3 lines,this is working very good using the header function.
I couldn't make it work as I imagined with the message:
"Web Page Expiered" as I can do it in ASP...
,, but at least it's gonna re-query the database for every single page..
Perfect!
Post Reply