Re: How can I configure setting a Header in httpd.conf based on content type?

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

 



i.e. if I do ExpiresByType application/msword "access plus 5 seconds" it doesn't actually work. Nor does
<FilesMatch "\.(doc|pdf)$">


 
On Thu, Mar 11, 2010 at 11:09 AM, Baljeet Nijjhar <baljeet.nijjhar@xxxxxxxxxxxxxx> wrote:
Hi
That works when distinguishing between html and images. However, I suspect my problem is more subtle. If the page contains an attachment (content-type = application/msword for example, rather than text/html) I need to set a different cache-control header. So are FilesMatch and ExpiresByType looking at the content-type header value and comparing, or something else?
Also, if I were to set my Header selectively in my application code for some cases, can I set my gloabl type settings in httpd.conf to only set the Header if it is not already present? That would help ..
thanks, Baljeet.

On Wed, Mar 10, 2010 at 3:33 PM, Philip Wigg <phil@xxxxxxxxxxxxxxxx> wrote:
On 10 March 2010 15:03, Baljeet Nijjhar <Baljeet.Nijjhar@xxxxxxxxx> 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@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