httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Baljeet Nijjhar <baljeet.nijj...@googlemail.com>
Subject Re: [users@httpd] How can I configure setting a Header in httpd.conf based on content type?
Date Thu, 11 Mar 2010 11:11:49 GMT
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@googlemail.com> 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@philipwigg.co.uk>wrote:
>
>> 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