'Clear Asset Cache Automatically' and slash/no-slash


(Douglas (@finnatic at @waikato)) #1

Our systems are both running 5.4.1.2 with the ‘Clear Asset Cache Automatically’ functionality enabled, but we’ve just noticed a difference between accessing a page with a trailing slash and without.

I manually cleared the Matrix cache and the difference disappeared. Could someone confirm that the ‘Clear Asset Cache Automatically’ behaviour actively clears the cache for both potential cache records? With slash and without e.g. Clark Kent and Superman…


(Marcus Fong) #2

If you’re seeing a difference between caching with and without a trailing slash, then I’d say the caching is occurring in a reverse proxy accelerator in front of Matrix rather than in Matrix itself.

Do you have “Redirect URLs with Trailing Slash?” enabled in System Configuration? It eliminates these caching differences, and has been on by default for quite some time.


(David Schoen) #3

As Marcus says, it’s been the default to have “Redirect URLs with Trailing Slash” on for a long time - it hides any issues here because the slashed version is always just a redirect to the primary (eliminating cache duplication).

If that’s off there is an option on “External Tools Configuration > Clear Squid Cache > Trailing Slash” - if set to True, it’ll clear the trailing slash versions as well - this started defaulting to false when the redirect option was added.


(Douglas (@finnatic at @waikato)) #4

We don’t, since we primarily run Apache out the front of our Matrix sites which expects the opposite behaviour as the default, as referred to in consider reversing the “strip trailing slash” redirect feature #11123.

Does that apply for the standard Matrix cache and Varnish as well or is just for those still using Squid?


(David Schoen) #5

All purges coming out from Matrix come from the “Clear Squid Cache” code (there’s been some discussion of fixing this, but it hasn’t happened yet). So yes, those settings apply regardless of what’s being used as a proxy cache in front of Matrix as long as Matrix functionality is being used to trigger a purge.

As long as it’s just proxying, this shouldn’t be an issue. Apache does default to having the trailing slash, but only for objects it understands (i.e if it’s serving a directory directly) mod_proxy/mod_rewrite won’t inject a trailing slash, they’ll just pass the request upstream.