Clearing SQUID cache on url with variable


(Kequi) #1

Hi,

 

Does anyone know of a way to clear the squid cache of a url with a variable?

 

As far as I know:

 

1. SQUID caches urls - including variables.

2. So the cache for www.mysite.com/mypage is different from www.mysite.com/mypage?tag=fromage

 

In Matrix there are various options including triggers - but they clear the SQUID cache on an ASSET basis - not a URL basis

 

If I clear the SQUID cache for asset ID123456 (which has webpath www.mysite.com/mypage) - that should clear the base url - but it won't touch the url with the variable (www.mysite.com/mypage?tag=fromage) - which will still show the cached version.

 

 

So - does anyone have any clever ideas on how to clear the SQUID cache for the url with the variable?

 

Thanks in advance

 

Karl


(Aleks Bochniak) #2

www.mysite.com/mypage/_recache?tag=fromag


(Kequi) #3

Thought I had tried that - and it just cleared SQUID for the asset (IE: the base url) and not the url with the variable.

 

I'll give it another go - thanks.


(Aleks Bochniak) #4

Do you have a trigger configured to clear squiz cache, when matrix cache is cleared?


(Kequi) #5

Hi Alex, 

 

 

I'll give that a go - however the clear squid cache trigger is also asset based - so unless it's somehow set to clear all urls with variables as well as the base url I'm not sure it will work.

 

I'll post back how it goes.

 

Thanks


(Bart Banda) #6

I don't believe you can, but haven't tried what Alex is suggesting so might work. We are planning on enhancing the clear cache tool and trigger action in Matrix to allow you to do this in a more dynamic and broad way though. 


(Marcus Fong) #7

The underlying problem here is really in Squid itself - as far as I’m aware, Squid can only purge by exact-match URL, and doesn’t allow any sort of wildcard matching with that. The Squid wiki mentions this under the section “How can I purge multiple objects from my cache?”:

“It’s not possible; you have to purge the objects one by one by URL. This is because squid doesn’t keep in memory the URL of every object it stores, but only a compact representation of it (a hash). Finding the hash given the URL is easy, the other way around is not possible. Purging by wildcard, by domain, by time period, etc. are unfortunately not possible at this time.”


As you’re a Squiz client, it might be best to talk to your Squiz account manager about your needs and see what options might be available.


(Kequi) #8

Thanks Bart, Marucs,

 

I've had no luck - so have resorted to adding a cache busting variable with a random number into the url link.

 

Fixes the issue I was having for now - but it's a bit of a pain as it then always bypasses Squid - I'll have to do till I can think of something else.

 

Thanks again

 

Karl


(Nick Ashton) #9

Given that it is impossible for Squiz to trigger a squid recache for URLs with variables, might the answer be to stop the Squid from caching them in the first place? I would think that the performance hit would be preferable to having an unbreakable cache.


(Marcus Fong) #10

Given that it is impossible for Squiz to trigger a squid recache for URLs with variables, might the answer be to stop the Squid from caching them in the first place? I would think that the performance hit would be preferable to having an unbreakable cache.

If that’s an adequate compromise for your situation, then you should be able to do it with a cache deny ACL in your Squid configuration.


(Bart Banda) #11

You can actually clear URLs in Squid with query strings now since version 5.3.1.1.

https://matrix-manuals.squiz.net/system-management/chapters/cache-manager#Clear-Cache-Screen


(Marcus Fong) #12

Oh, the new feature allowing you to clear arbitrary URLs? That works, provided you know exactly what query string you want to clear (including the variable order).