You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Joshua Slive <jo...@slive.ca> on 2006/12/09 23:09:16 UTC
Re: [users@httpd] determine cache or no cache of dynamic content
On 12/9/06, allan juul <al...@muly.dk> wrote:
> hello,
>
>
> [win2003 / apache 2.2]
>
> using mod_disk_cache and mod_rewrite we are trying to cache responses
> with rarely updated but dynamic content served from a heavy loaded backend.
>
> how can one determine if a certain request is actually served from the
> cache and not the backend from where it originally came from ?
Check the Age HTTP response header. If the proxy sends this header
with a non-zero value, it is using the cache.
Note that the response headers from your backend don't seem to give
much lee-way for caching with only 2 seconds difference between the
date and expires header and you have no HTTP/1.1 caching stuff
(cache-control).
Joshua.
>
> we can see our disk cache is growing, but assuming we (via script for
> example) just hit the same URL over and over again, would it not then be
> possible to turn off the backend server completely and our frontend
> would still work happily serving from the disk cache? (that test would
> work if it was a static file like a gif image it seems)
>
> below are relevant parts from configuration and response headers
>
> thanks
> ./allan
>
> conf
> ----
> RewriteEngine On
> RewriteRule ^/(.*) http://remote.backend.com:12345/$1 [proxy,last]
>
> CacheEnable disk /
> CacheDefaultExpire 3600
> CacheRoot d:/cacherootlocalhost
> CacheDirLevels 5
> CacheDirLength 3
>
>
>
> response headers from backend (http statuscode = 200)
> -----------------------------
> Connection: close
> Date: Sat, 09 Dec 2006 21:13:53 GMT
> Allow: GET
> Content-Length: 756
> Content-Type: text/xml; charset=UTF-8
> Expires: Sat, 09 Dec 2006 21:13:55 GMT
> Client-Date: Sat, 09 Dec 2006 21:13:53 GMT
> Client-Peer: 127.0.0.1:80
> Client-Response-Num: 1
>
>
>
> ---------------------------------------------------------------------
> 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@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
---------------------------------------------------------------------
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@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] determine cache or no cache of dynamic content
Posted by allan juul <al...@muly.dk>.
Joshua Slive wrote:
> On 12/9/06, allan juul <al...@muly.dk> wrote:
> But you are better off simply sending reasonable Cache-Control and
> expires headers from your back-end. That will make your cache work,
> and will also help other caches along the way. If you really can't do
> that (because you want the apache cache using different settings than
> the foreign caches), just don't send the expires at all from the
> back-end, use CacheIgnoreNoLastMod, CacheDefaultExpire, and then use
> mod_expires to set a new Expires/Cache-Control at the proxy.
>
> Joshua.
thanks,
i'm not 100% sure we can actually fo that. we are able (at apache level)
to unset or set the Expires header to a hardcoded value. if we are
unable to set the Expires header at the backend (i'm currently not aure
of this) are you saying that mod_expires can actuallt overwrite it. if
so i can't figure out the syntax of this. At least these are not enough
ExpiresActive On
ExpiresDefault "access plus 1 month"
taking it a bit further, is it possible to calculate and set an Expires
header and then use the *mod_headers* module. for example this hardcoded
directive would overwrite the backend's Expires header in our case, but
is not very useful/scalable:
Header set Expires "Sat, 16 Dec 2006 23:54:46 GMT"
./allan
---------------------------------------------------------------------
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@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] determine cache or no cache of dynamic content
Posted by Joshua Slive <jo...@slive.ca>.
On 12/9/06, allan juul <al...@muly.dk> wrote:
> hi Joshua,
>
> thanks for the quick reply
>
> Joshua Slive wrote:
> > On 12/9/06, allan juul <al...@muly.dk> wrote:
> >> how can one determine if a certain request is actually served from the
> >> cache and not the backend from where it originally came from ?
> >
> > Check the Age HTTP response header. If the proxy sends this header
> > with a non-zero value, it is using the cache.
>
> in other words, if no AGE is set, i can assume our disk cache is ignored
> ? but why does it fill the cache then if it's not going to use it ?
It puts the stuff in the cache if there is some chance it can be used
(even if that chance only lasts for 2 seconds). Whether it is
actually used or not depends on the conditions of subsequent requests.
> > Note that the response headers from your backend don't seem to give
> > much lee-way for caching with only 2 seconds difference between the
> > date and expires header and you have no HTTP/1.1 caching stuff
> > (cache-control).
> i see what you mean, hmm, what would be normal Expires difference be (an
> hour or so)?
That depends entirely on your content. You should set Expires and
Cache-Control based on your freshness requirements.
>
> Is it actually possible to ignore it completely, something like?
>
> CacheIgnoreHeaders Expires
> CacheDefaultExpire 86400
I don't know if that will work. CacheIgnoreHeaders if for controlling
storage of hop-by-hop headers, not for monkeying with freshness.
You'd also need at least CacheIgnoreNoLastMod in your case.
But you are better off simply sending reasonable Cache-Control and
expires headers from your back-end. That will make your cache work,
and will also help other caches along the way. If you really can't do
that (because you want the apache cache using different settings than
the foreign caches), just don't send the expires at all from the
back-end, use CacheIgnoreNoLastMod, CacheDefaultExpire, and then use
mod_expires to set a new Expires/Cache-Control at the proxy.
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@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] determine cache or no cache of dynamic content
Posted by allan juul <al...@muly.dk>.
hi Joshua,
thanks for the quick reply
Joshua Slive wrote:
> On 12/9/06, allan juul <al...@muly.dk> wrote:
>> how can one determine if a certain request is actually served from the
>> cache and not the backend from where it originally came from ?
>
> Check the Age HTTP response header. If the proxy sends this header
> with a non-zero value, it is using the cache.
in other words, if no AGE is set, i can assume our disk cache is ignored
? but why does it fill the cache then if it's not going to use it ?
> Note that the response headers from your backend don't seem to give
> much lee-way for caching with only 2 seconds difference between the
> date and expires header and you have no HTTP/1.1 caching stuff
> (cache-control).
>
> Joshua.
i see what you mean, hmm, what would be normal Expires difference be (an
hour or so)?
Is it actually possible to ignore it completely, something like?
CacheIgnoreHeaders Expires
CacheDefaultExpire 86400
./a
---------------------------------------------------------------------
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@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org