Re: [squid-users] refersh_pattern cache dynamic extensions

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Thu, 02 Dec 2010 01:01:01 +1300

On 01/12/10 08:56, Ghassan Gharabli wrote:
> Hello,
>
> I have several questions to ask about refresh_pattern
>
> sometimes I see configuration as
>
> refresh_pattern -i *.ico$

Single extension for exact file path. Not matching when query ("?")
parameters are present. Case does not matter.

> refresh_pattern -i .(css|js|xml) #multiple extensions

Any string containing at least three bytes. Containing "js" or "css" or
"xml" anywhere after the first byte. Case does not matter.

> refresh_pattern \.(css|js|xml)

Any string containing at least three bytes. Three of which are ".js" or
four of which are ".css" or ".xml". Lower case only.

> refresh_pattern \.(css|js|xml)$

Any string containing at least three bytes. Three of which are ".js" or
four of which are ".css" or ".xml". Lower case only. Might match the end
of a domain name or query ("?") parameters.

> refresh_pattern -i .(css|js|xml)$

Any string containing at least three bytes. Ending with "js" or "css" or
"xml". Case does not matter. Might match the end of a domain name or
query ("?") parameters.

> refresh_pattern .(\?.*)?$

Any string. Absolutely *everything*.
The above is a equivalent to: .

>
> Please can anyone explain what is the difference between each example
> and I have also another question like how to cache multiple extensions
> using the same rule incase it was dynamic or static

The pattern style I'm recommending for modern traffic is this:

   refresh_pattern -i \.(a|b|c|d)(?.*)?$

to match the files with extension .a .b .c or .d regardless of case or
whether parameter garbage has been appended.

Web2.0 download sites use parameters a lot more for two reasons:
  * to hide the file extension away from people using the old pattern to
break the sites.
  * to add extra details which may be useful for caching variants. ie
two sizes of the same image or two high/low definition of the same video.

>
> example :
> #I know this rule catches dynamic website or file but i dont know how
> to deal with multiple extensions like gif , jpeg , png
> refresh_pattern .(\?.*)?$
>
> Why we put $ , ? or \?.*

They are part of regex code.

Please search the web for tutorials on regex patterns (POSIX extended
regex to be precise) and learn how they work and how to use them before
going any further. Making a mistake with them has big trouble as a
consequence.
  Note how many of my explanations start with the words "Any string".

Amos

-- 
Please be using
   Current Stable Squid 2.7.STABLE9 or 3.1.9
   Beta testers wanted for 3.2.0.3
Received on Wed Dec 01 2010 - 12:01:07 MST

This archive was generated by hypermail 2.2.0 : Wed Dec 01 2010 - 12:00:03 MST