I don't understand the following:

In Drupal 7's default .htaccess file the Apache module mod_expires is ordered to let files without a .php extension expire after two weeks.

How is web development with this setting possible? When I change a .css file, I want the changes to be reflected immediately. Do browsers ignore the expiration setting?

I've stumbled upon this issue because I'm currently experiencing troubles with a Varnish caching system. I currently do not know what causes my files not to be refreshed immediately.

1 Answer 1


The Cache-Control header which mod_expires sets tells the browser when a set of cached content should expire and be redownloaded. If you are interested in learning more about how that header works, read http://blog.httpwatch.com/2007/12/10/two-simple-rules-for-http-caching/ it explains it really well. Browsers do not ignore this setting. But if you "shift reload" or do something which forces the browser to ignore the cache and redownload anyways you'll ignore it.

A common approach for this is to implement a timestamp based update for CSS/JS. For example you have the following stylesheet link

<link rel="stylesheet" type="text/css" media="all" href="style.css">

You would append a last changes tag to it, something like

<link rel="stylesheet" type="text/css" media="all" href="style.css?c=20131001">

and then you can just auto increment this every time you change the css. This will force ALL browsers to redownload, but won't destroy the cache benefits.

  • 1
    Can you elaborate on how Drupal handles this?
    – mpdonadio
    Commented Oct 1, 2013 at 22:07
  • @mpdonadio the only way "Drupal handles this" is by setting the value for ExpiresDefault to A1209600 in the .htaccess file it ships with.
    – jenlampton
    Commented Jul 4, 2019 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.