1

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 ?

Anny
  • 11
  • 2
  • 1
    I think the above is valid syntax in apache http 2.2 as well, what happens when you tried that? – HBruijn Sep 10 '18 at 07:11
  • @ HBrujin, yes I tried. It resulted me syntax error. "envclause should be in the form env=envar" – Anny Sep 10 '18 at 08:33

1 Answers1

0

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
  • 72,524
  • 21
  • 127
  • 192