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 am trying to set a cache control header when a browser requsets the following url:

As even though getData.php is a dynamic page, when the parameter exampleField equals exampleValue the response doesnt change. Therefore, there is no reason for the browser not to cache this result. My question is how do I write a FilesMatch rule in the .htaccess file to match this, I tried the following with no luck:

<FilesMatch "php/getData.php\?exampleField=(exampleValue1|exampleValue2)$">
Header set Cache-Control "max-age=3024000, must-revalidate"
share|improve this question

The GET parameters are not part of the filename, so <FilesMatch> will not match them.

Given that you are serving up a PHP file, have you considered simply adding the cache control header there?

  /* ... */
  if (
    @isset( $_GET['exampleField'] ) &&
    $_GET['exampleField'] == 'exampleValue'
  ) {
    header('Cache-Control "max-age=3024000, must-revalidate"');
  /* ... */
share|improve this answer
hmm I will give this a try tonight – Aly Mar 14 '11 at 8:21

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.