httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Wigg <p...@philipwigg.co.uk>
Subject Re: [users@httpd] How can I configure setting a Header in httpd.conf based on content type?
Date Wed, 10 Mar 2010 15:33:54 GMT
On 10 March 2010 15:03, Baljeet Nijjhar <Baljeet.Nijjhar@gmail.com> wrote:
>
> Hi
> I'd like to try and configure the following outcomes in my httpd.conf:
> a) for static images, stylesheets, javascript, Cache-Control:max-age
> 3600 and Expires: + 3600. This I can easily do by using the ExpiresByType
> directive for these content types (text/css, application/x-javascript,
> image/* etc)
> b) for html, I want to set Cache-Control: no-cache, no-store (and probably
> Pragma to no-cache or Expires to -1 to prevent HTTP 1.0 from caching). I'd
> rather not use max-age=0 because that will download my pages to the user's
> browser.
> I can't see how to do b) i.e. define a different Header based on the
> content-type which seems to be text/html. I've tried enclosing my Header set
> command within a <FilesMatch "\.(htm|html)$"> directive, but this doesn't
> seem to match my HTML.
> Has anyone got any ideas please? Do I need to add a Directory of where my
> application is? (I'm using a proxy server and my application server is on
> another machine, so I don't know how easily I can do this, if needed).

One way might be to use the Header directive to set 'Cache-Control:
no-cache' as the default and then override it for selected file types
that you do want to cache? Something like:-

Header set Cache-Control "no-cache"

<FilesMatch "\.(gif|jpg|jpeg|png|js|css|swf)$">
    Header set Cache-Control "max-age=3600"
</FilesMatch>

-- Phil

---------------------------------------------------------------------
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


Mime
View raw message