Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to set a cache control header when a browser requsets the following url:

www.example.com/php/getData.php?exampleField=exampleValue

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"
</FilesMatch>
share|improve this question
add comment

1 Answer

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?

<?php
  /* ... */
  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
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.