Re: Apache dynamic page caching?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 16, 2008 at 1:41 PM, howard chen <howachen@xxxxxxxxx> wrote:
> Hi all,
>
>
>  On Wed, Apr 16, 2008 at 9:21 PM, Narendra Verma
>  <narendra.verma@xxxxxxxxxxxxx> wrote:
>  > Hi Howard,
>  >  1. Be sure to load following module
>  >
>  >     LoadModule headers_module modules/mod_headers.so
>  >
>  >  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 (http://en.wikipedia.org/wiki/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
htcacheclean.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux