Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've borrowed some mod_expires code from the HTML5 Boilerplate that adds some sensible defaults for asset expiry (I have filename version revving configured with htaccess so I can add mtimes before asset extensions like script.123456789.js):

ExpiresActive on
ExpiresDefault                                      "access plus 1 month"

ExpiresByType text/css                              "access plus 1 year"

# Data interchange
ExpiresByType application/json                      "access plus 0 seconds"
ExpiresByType application/xml                       "access plus 0 seconds"
ExpiresByType text/xml                              "access plus 0 seconds"

# ... etc ...

However, I'd like to disable these on my development server (which sets a DEVELOPMENT=1 environment variable). Is it possible to conditionally disable mod_expires (perhaps ExpiresActive On) in 2.4.4 like you can with mod_access if an environment variable is set (Allow from env=DEVELOPMENT) ?

share|improve this question
up vote 2 down vote accepted

I don't know any easy way of doing this based on the value of an environment variable. You might be able to figure out a way with mod_rewrite, but it would be ugly.

An easier method is to have your development server set a command-line switch, -DDEVELOPMENT, for Apache, instead of (or in addition to) the environment variable. Then the Apache config becomes trivial:

ExpiresActive on

The right place to set the switch depends on your distro. In Debian & family, you set


in /etc/apache2/envvars. In RHEL, you set


in /etc/sysconfig/httpd.

share|improve this answer
+1 This is genius! Plus it's part of the core so my host won't choke on <IfDefine>. Many thanks! – Bailey Parker Jul 14 '13 at 6:48
Good :) One thing to add is that command-line switches apply to all virtual hosts on your server. But for something general like -DDEVELOPMENT that's probably fine. – Andrew Schulman Jul 14 '13 at 10:29

Your Answer


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.