Forum Moderators: coopster

Message Too Old, No Replies

Php Header Vs Htaccess Header

         

yaashul

4:59 am on Aug 25, 2011 (gmt 0)

10+ Year Member Top Contributors Of The Month



I have set the following thing in .htaccess

<FilesMatch "\.(html|htm|cgi|pl|php)$">
Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
</FilesMatch>


It tell that no php script shud be cached by browser or other user-agent.

But if I want only 1 php script to use other setting I can use

header('Cache-Control: public');

function in that script. But the problem is php is not able to change the header setting done in .htaccess?


<?php
header('Cache-Control: public');
?>



showing the following header

Cache-Control:max-age=0, private, no-store, no-cache, must-revalidate

while it shud show

Cache-Control: public

Any specific reasons?

rocknbil

4:40 pm on Aug 26, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Headers are already set, you can only reset the headers if you redirect, but then it will hit the .htaccess again on the next request.

Personally I'd use a conditional directly in the .htaccess to ignore the one that's different . . . ask in the Apache forum.