You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Marko Asplund <ma...@ixonos.com> on 2008/04/30 14:37:41 UTC

[users@httpd] Cache configuration advice

I'm developing a public web site on top of a CMS product running in
Apache Tomcat. The site will have a caching Apache httpd 2.2 reverse
proxy in front of Tomcat.
Since my experience with caching Apache reverse proxy setups is limited
I'd appreciate any feedback on the current setup plan.

Page content will be cached with Apache using mod_cache and
mod_disk_cache. Certain parts of the URL space contain non-cacheable
content.
Page content should be cached for 5 minutes and images for 1 hour.
Several pages contain paged lists of data (e.g. news items). Paging
state is passed in HTTP request parameters and also paged content should
be cached. The backend system doesn't set any HTTP cache related headers
such as the Expires header when a page is served.
For usage statistics gathering purposes page content should not be
cacheable neither in the browser nor in any intermediate forward
proxies, if possible.

Below is the configuration file draft I've come up with.
Does the setup fulfill the requirements above?
Any other comments?

As far as I've understood the below setup would not correctly cache
request content when using request parameters (requires Expires header).
What would be the best way to fix this?

How will the Cache-Control and Expires (ExpiresByType) work together?

Is it possible to have the cache asynchronously update cached content so
that the last request would be served with expired content but behind
the scenes the cache would update the content once expired content is
requested?


<VirtualHost 10.0.0.1:80>
  ProxyPass / ajp://127.0.0.1:8009/

  # cache content by default for 5 minutes
  <Location />
    Deny from all
    Header set Cache-Control s-maxage=300
  </Location>

  # allow access to certain subspaces only
  <Location /mysite/>
    Allow from all
  </Location>

  CacheRoot /opt/mysite/httpd/cache
  CacheEnable disk /

  # disable caching for certain parts of the URL space
  CacheDisable /comment/
  <Location /mysite/comment/>
    Header set Cache-Control no-cache
  </Location>

  CacheIgnoreNoLastMod On
  CacheIgnoreHeaders Cookie

  # cache images for one hour, browser caching allowed
  ExpiresActive On
  ExpiresByType image/gif "now plus 1 hours"
  ExpiresByType image/jpeg "now plus 1 hours"
  ExpiresByType image/png "now plus 1 hours"
  ExpiresByType text/css "now plus 1 hours"
</VirtualHost>



---------------------------------------------------------------------
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] Cache configuration advice

Posted by Joshua Slive <jo...@slive.ca>.
On Wed, Apr 30, 2008 at 8:37 AM, Marko Asplund <ma...@ixonos.com> wrote:

>  As far as I've understood the below setup would not correctly cache
>  request content when using request parameters (requires Expires header).
>  What would be the best way to fix this?

See the CacheIgnoreQueryString directive.

>
>  How will the Cache-Control and Expires (ExpiresByType) work together?

The Expires* directives also set max-age on Cache-Control.

Using those directives, you are influencing how down-stream caches
will behave, not the local cache. The local cache would need to see
those directives coming from the upstream (if I remember correctly).

You'll want to use the CacheDefaultExpire directive to control the
local cache. Unfortunately, I don't think it is possible to set
different expiration times within the same host, since this directive
can't be placed in <Directory>/<Location> sections.

>
>  Is it possible to have the cache asynchronously update cached content so
>  that the last request would be served with expired content but behind
>  the scenes the cache would update the content once expired content is
>  requested?

This feature has been discussed by the developers, but is not
currently implemented to the best of my knowledge.

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