[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: squid cache



On Fri, Oct 12, 2001 at 03:41:02PM +1000, Brian May wrote:

> how do you get squid to *cache* data?
> 
> I tried using the following in my squid configuration:
> 
> refresh_pattern         \.deb$          43200   100%    43200 override-lastmod ignore-reload
> refresh_pattern         Release$        720     100%    720 override-lastmod ignore-reload
> refresh_pattern         Packages.gz$    720     100%    720 override-lastmod ignore-reload
> refresh_pattern         Sources.gz$     720     100%    720 override-lastmod ignore-reload
> 
> however, I just did a "apt-get update" on one computer, and went
> straight to another computer and typed in the same command (same
> sources.list file), and now it has to re-download everything again.
> 
> arrrgghhh!
> 
> How do I stop this? Is there anyway I can find out what is going
> wrong? This is no way to reduce my volume charge fees...

It's terribly awkward, I'm afraid, but from looking at the code, the
comments in the example squid.conf appear to be accurate:

#       Please see the file doc/Release-Notes-1.1.txt for a full
#       description of Squid's refresh algorithm.  Basically a
#       cached object is: (the order is changed from 1.1.X)
#
#               FRESH if expires < now, else STALE
#               STALE if age > max
#               FRESH if lm-factor < percent, else STALE
#               FRESH if age < min
#               else STALE

So in the default mode of operation, the "min" parameter never comes
into play unless the Last-Modified header is absent.

For a while, I was using a huge "percent" parameter to cause it to
always bypass that check, and use the "min" age:

refresh_pattern         Packages\.gz$   1440    1000%   1440
refresh_pattern         Sources\.gz$    1440    1000%   1440
refresh_pattern         \.orig.tar.gz$  43200   1000%   43200
refresh_pattern         \.deb$          43200   1000%   43200
refresh_pattern         \.dsc$          43200   1000%   43200

This has worked well in the past, but recently I've traded one ugliness
for another, and I'm violating the RFC using override-lastmod:

refresh_pattern         Packages\.gz$   1440    0%      1440 override-lastmod
refresh_pattern         Sources\.gz$    1440    0%      1440 override-lastmod
refresh_pattern         \.orig.tar.gz$  43200   0%      43200 override-lastmod
refresh_pattern         \.deb$          43200   0%      43200 override-lastmod
refresh_pattern         \.dsc$          43200   0%      43200 override-lastmod

override-lastmod essentially moves the "FRESH if age < min" check ahead
of the lm-factor check.  So as long as the object is younger than min,
it will be considered fresh, otherwise, the lm-factor test is computed.
This should be more correct (in terms of what I want) than the previous
configuration, and it seems to work, but I haven't tested it thoroughly
yet.

My parameters cause Packages and Sources to be considered fresh for one
day from their last modification time, after which they will immediately
become stale (this is appropriate for unstable; the defaults are more
appropriate for stable).  .orig.tar.gz, .deb and .dsc stay fresh for 30
days, which is essentially forever.

I use the default 4096kb maximum_object_size and an 800MB cache_dir.

What do you see in the squid logs when you do the second update through
the proxy?  Are you getting a miss?  Are you certain that the second
system is properly utilizing the proxy?

-- 
 - mdz



Reply to: