You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Diana Horvitz <Di...@exlibris.co.il> on 2005/05/10 08:32:02 UTC

RE: [users@httpd] "Expires" and "Cache-Control" don't work proper ly

Hi Axel,

Thanks for your answer.
Running "httpd -l", I don't see neither mod_cache nor mod_disk_cache - can
the problem be here?

The elements are cached by the browser (both IE and NS 7).
I'll try to clarify:
- The URLs are added to the history. If you try to access one of such URLs
from the history, the request goes to the application and it knows how to
deal with the request.
- However, if you open the list under the browser's "Back" button and click
on one of the entries there, the page is displayed, but the request never
reaches the application, therefore I assume it is taken from the cache.
- In addition, I have found that, once you click on one of those entries
(and get the page), all the entries following that one disappear.

I can't have the application set the appropriate headers. I have also tried
META tags with no success.
If I could have the application set the headers, how do I tell Apache not to
override them?

I have tried the configuration you sent, it doesn't seem to help.

Thanks again, any idea is welcome

Diana

-----Original Message-----
From: Axel-Stéphane SMORGRAV [mailto:Axel-Stephane.SMORGRAV@europe.adp.com] 
Sent: Monday, May 09, 2005 10:51 AM
To: users@httpd.apache.org
Subject: RE: [users@httpd] "Expires" and "Cache-Control" don't work properly

Actually "Expires" and "Cache-Control" do work properly. Don't you see those
headers in the response received by your browser? Are the elements cached by
your browser?
 
I believe that the behaviour you observe may be due to the order in which
mod_header and mod_cache process the response. My guess is that mod_headers
intervenes on the response after mod_cache. At the time the responses are
processed by mod_cache, the "Expires" and "Cache-Control" headers have not
yet been inserted.
 
If you are using mod_disk_cache you can verify this by browsing one of the
.header files created in the cache directory. If those files do not contain
the "Expires" and "Cache-Control" headers, chances are that these headers
are inserted into the response after having been processed by mod_cache.
 
Your configuration is not very consistent either since you on one hand set
"ExpiresActive On", and on the other explicitly do "Header set" and "Header
unset" on files for which you have defined "ExpireByType". 
 
If the pages are generated "on the fly", why don't you have the application
set the apropriate headers??
 
If the pages are generated "on the fly", they probably do not have
LastModified, ETag or Expires headers. If that is the case, they will not be
cache by Apache (no cache validator).

If I am right about the order in which the different modules/filters are
processed, and you cannot have the application set the correct headers, you
will probably need to make a two-stage rocket, i.e. two virtual hosts where
the frontal is a caching reverse proxy whose task is to forward requests to
the backend and cache responses if they are cacheable, and the backend takes
care of inserting the correct headers. I would also take a little different
approach wrt.the configuration and try something like this:


ExpiresDefault "now"

ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType text/css  A2592000

ExpiresActive on

<LocationMatch "!\.(css|jpe?g|png|css|sav)$">
    Header set Pragma "no-cache"
    Header set Cache-Control "no-cache, must-revalidate"
</LocationMatch>

-ascs
________________________________

-------------------------------------------------------- 
This message has been scanned for viruses and
dangerous content by Ex Libris Ltd, and is
believed to be clean.
--------------------------------------------------------