Prevent browser-caching of /panel

I’d like to cache normal/public Pages and other files for 1 day, but I also want to prevent the panel-folder to be cached. I tried this solution via htaccess:

<IfModule mod_expires.c>
	<If "%{REQUEST_URI} =~ m#^/panel/#"> 
		ExpiresActive Off
		Header set Cache-Control "private, max-age=0, no-cache, no-store, proxy-revalidate, must-revalidate, no-transform"		
	</If>
	<Else>
		ExpiresActive On
		ExpiresDefault "access plus 1 days"
		Header set Cache-Control "public, max-age=86400, no-transform"
	</Else>
</IfModule>

But it doesn’t work.

Even though EVERY other file in a request will follow this rule, the html-file doesn’t want to and independently if it’s a normal/public page or e.g. the login-page inside the panel-folder. The header of those files shows always

max-age=0, no-cache, no-transform

So not, what I’ve ordered. Obviously there’s a different Rule somewhere forcing this and which will skip my snippet in the htaccess. OR this if-condition

<If "%{REQUEST_URI} =~ m#^/panel/#">

is wrong. Any idea to fix it?

Never, ever cache HTML in the browser.

The Cache-Control directives are usually for assets such as images/javascript/…

1 Like