cache control to a specific file .

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

cache control to a specific file .

Post by lovelf »

Hello, I am trying to set an expiry time to one file but it gets the same expiry time that the rest of the files get.

Code: Select all

<FilesMatch "file.php">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>
<FilesMatch ".*">
  Header set Cache-Control "max-age=259200, must-revalidate"
</FilesMatch>
file.php gets 259200 instead of 7200, why is this?

Is the code above wrong?

Thanks.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: cache control to a specific file .

Post by Christopher »

Try:

Code: Select all

<FilesMatch ".*">
  Header set Cache-Control "max-age=259200, must-revalidate"
</FilesMatch>
<FilesMatch "file.php">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>
(#10850)
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

Re: cache control to a specific file .

Post by lovelf »

That is the proper way, thank you. :drunk:
Post Reply