Best practices for setting lm-factor in Squid refresh patterns

debian-squeezesquid

I am running a Squid (3.1) cache in front of Django. The content of the site does not change very often, so Squid gives our backend much needed breathing room.

Currently, this is the refresh pattern that we are using to cache the content:

refresh_pattern . 60 100% 60
We basically want to cache everything for at least an hour (and only an hour) before Squid then re-validates the content.

My question is on the "100%" parameter, which sets the lm-factor.

I'm not sure if setting that to 100% is doing what we want it to. The assumption was that by setting it to 100%, it would ensure that objects stay in the cache for the max cache time.

Is this an incorrect assumption?

What are the best practices that one should follow when setting up a refresh pattern like this?

Best Answer

As the reference states :

Percent' is a percentage of the objects age (time since last modification age) an object without explicit expiry time will be considered fresh.

(http://www.squid-cache.org/Doc/config/refresh_pattern/)

It means that for a 1-day-old object and a factor of 50%, the object will be consider fresh for 12h. And in addition, it would be consider fresh at least for the min time and at most for the max time.

The idea is to consider that an older object as less chance to become stale than a newer one.

With your refresh pattern, all objects are cached for 60 minutes exactly so the lm-factor does not really matter. I would recommend to keep it at 100%. I don't know what would happen with a factor of 0%, if anyone has a clue ?

The lm-factor would be more important if your max time was higher than your min time.

Related Topic