httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joshua Slive" <>
Subject Re: [users@httpd] Apache dynamic page caching?
Date Wed, 16 Apr 2008 18:22:19 GMT
On Wed, Apr 16, 2008 at 1:41 PM, howard chen <> wrote:
> Hi all,
>  On Wed, Apr 16, 2008 at 9:21 PM, Narendra Verma
>  <> wrote:
>  > Hi Howard,
>  >  1. Be sure to load following module
>  >
>  >     LoadModule headers_module modules/
>  >
>  >  2. Add following Header directive at the last of httpd.conf file.
>  >
>  >     Header add Cache-Control max-age=3600              (in seconds)
>  >
>  >  Here we can decide that what is the maximum age of cached response.
>  >  If max-age passed then apache again sends request to backend(tomcat) for re-caching,
if the body of response is not found modified then 304 status is found means existing cache
would be used.If body changed then then it is re-cached. You can use any amount of time to
decide re-caching.
>  >
>  The problem is I don't know to cache for how long. Maybe 1 month, or
>  maybe one second, consider a blog post, it will be only updated when a
>  user leave a comment, but the exact time is unpredictable.
>  Currently I am using PHP / Smarty cache, if a user leave a comment, I
>  will remove cache from the file system and the cache will be
>  re-generated next time if cache miss.
>  The only draw back is since for a cached case, I am sending HTML via
>  PHP, so why I don't send the cache via Apache? The lighttpd Cache Meta
>  Language ( is what
>  exactly doing what I want, but I am just wondering if Apache users
>  have think of this before? )
>  On the other hand, mod_cache seems can't do what I want. Squid did
>  (wikipedia is using similar approach with "purge' multicast). Of coz
>  setting a squid is another overhead for my simple use.

How, exactly, did you have squid configured?

There are two ways to handle this problem in general:

1. You check for cache freshness on every request; or
2. You invalidate the cache when you know it becomes bad.

For the first option, apache will send if-modified-since requests to
the back-end on expired content (if the cache is in its own http
layer). You can tune your php code to handle these quickly for the
not-modified case, letting the cache send its copy.

For the second option, there are two ways to invalidate a cache entry.
First, you can send an HTTP request to the cache with Cache-control:
max-age=0. Second, you can manipulate the cache directly on the
filesystem. To see how this works, see the source code to


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message