2

Is there any method to call RESPONSE_CODE in http.conf file --> check if it is ="404" --> Disable cache for 404 ONLY..

P.S. I am using Apache 2.2.

For apache 2.4 I saw some help as below:

<IfModule mod_headers.c>        
 Header always unset ETag "expr=%{REQUEST_STATUS} == 404"
 Header always set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" "expr=%{REQUEST_STATUS} == 404"    
 Header always set Pragma "no-cache" "expr=%{REQUEST_STATUS} == 404"    
 Header always set Expires "Wed, 11 Jan 1984 05:00:00 GMT" "expr=%{REQUEST_STATUS} == 404"    
</IfModule>

Any help in apache 2.2 ?

Revious
  • 207
Anny
  • 21

1 Answers1

1

I think you should at least be able add headers when you set up custom error pages with an ErrorDocument Directive and then add Header directives on the Location of the custom error pages.

ErrorDocument 404 /error-pages/404.html
ErrorDocument 500 /error-pages/500.html

<Location /error-pages/>
     Header always unset ETag
     Header always set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
     Header always set Pragma "no-cache" 
</Location
HBruijn
  • 84,206
  • 24
  • 145
  • 224