Time for action – calculating the freshness of cached objects
Let's see an example of a refresh_pattern
and try to calculate the freshness of an object:
refresh_patten -i ^http://example.com/test.jpg$ 0 60% 1440
Let's say a client requested the image at http://example.com/text.jpg
an hour ago, and the image was last modified (created) on the web server six hours ago. Let's assume that the web server didn't specify the expiry time. So, we have the following values for the different variables:
At the time of the request, the object age was (6 - 1) = 5 hours.
Currently, the response age is 1 hour.
Currently, the
lm-factor
is 1÷5 = 20 percent
Let's check whether the object is still fresh or not:
The response age is 60 minutes, which is not more than 1440 (
max
value), so this can't be the deciding factor.lm-factor
is 20 percent, which is less than 60 percent, so the object is still fresh.
Now, let's calculate the time when the object will expire. The object age is 5 hours and percent value is 60 percent...