PDA

View Full Version : Make page not cache but let images


Extreme43
06-17-2005, 12:53 PM
How would i make the page not cache but allow an image (logo) to be cached ?

NeilKelty
06-29-2005, 03:11 PM
I think its more the users choice on a chached page. Unless you add some kind of datestamp and trick the browser into thinking it is a new page and then it will load it agian.

Extreme43
07-02-2005, 07:02 AM
well i use

<META Http-Equiv="Cache-Control" Content="no-cache">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Expires" Content="0">

in the header page

Span
07-03-2005, 08:00 PM
The only right way to do that is server-side. Meta's won't work.
This is for Apache's .htaccess:

ExpiresActive On
ExpiresByType text/html A0
ExpiresByType image/gif A5184000
ExpiresByType image/jpeg A5184000

A = client's acces time
0 is "zero seconds", so html files won't be cached
5184000 (seconds) is 60 days

You could also use a FilesMatch container to match files by their name:

ExpiresActive On
<FilesMatch "^index.html$">
ExpiresDefault A0
Header unset Cache-Control:
Header append Cache-Control: "no-cache, must-revalidate"
</FilesMatch>

<FilesMatch "^logo.jpg$">
ExpiresDefault A2592000
</FilesMatch>

More about caching: http://www.mnot.net/cache_docs/
Apache (2.X) mod_expires : http://httpd.apache.org/docs-2.0/mod/mod_expires.html