Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a site with Apache 2.2.22 . I have enabled the mod-expires and mod-headers modules seemingly correctly:

$ apachectl -t -D DUMP_MODULES
…
expires_module (shared)
headers_module (shared)
…

Settings include:

ExpiresActive On
ExpiresDefault "access plus 10 minutes"
ExpiresByType application/xml "access plus 1 minute"

Checking the headers of requests, I see that max-age is set correctly both for the generic case and for xml files (which are auto-generated, but mostly static).

I would like to have different expiries for xml files in a directory (e.g. /data), so http://site/data/sample.xml expires 24 hours later.

I enter the following in data/.htaccess:

ExpiresByType application/xml "access plus 24 hours"
Header set Cache-control "max-age=86400, public"

but it seems that apache ignores this.

How can I ensure apache2 uses the .htaccess directives? I can provide further information if requested.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Since you have access to the core configuration file, it would be preferable to write it directly in there, under a directory section like so:

<Directory /var/www/data>
  ExpiresByType application/xml "access plus 24 hours"
  Header set Cache-control "max-age=86400, public"
</Directory>

If you really want to use an .htaccess file, make sure you have:

<Directory /var/www/data>
    AllowOverride All
</Directory>
share|improve this answer
    
Yes, using the core configuration file is a solid advice; what I didn't clarify was that I want to delegate expiration control to others who don't have write access to the apache configuration. The AllowOverride option did it. Thanks. –  tzot Nov 5 '12 at 13:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.