[squid-users] Is it possible to modify cached object?

Alex Rousskov rousskov at measurement-factory.com
Fri Jan 6 19:21:16 UTC 2017


On 01/06/2017 11:35 AM, boruc wrote:

> I am facing a really big problem (for me). I've set up a home network (few
> PCs, some mobiles) with squid proxying all requests. Is it possible to
> change cached objects manually? Let's say I have an object that contains
> /www.example.com/ page HTML source and what I want to do is e.g. change some
> words so users will see modified pages. I won't do this with HTTPS of
> course, just HTTP.
> 
> I tried to do that (I've changed one letter, so content length won't
> change), but after refreshing a page that cached file disappeared. Here's my
> refresh_pattern config section:
> 
> 
> 
> Or maybe there's another way to achieve my goal with squid?

If you just want to change one or two cached files once and do not care
that they will be replaced by fresher copies eventually (possibly
immediately; see P.S.), then you can very carefully hand-edit the cached
content on disk and restart Squid (to get rid of in-memory cached
copies, if any). You have to preserve the old content length of the
edited response and all [binary] metadata. Most editors will not do that
for you. A response may even contain a Content-MD5 checksum. This hack
is technically possible in some cases but it is unsupported.

Otherwise, what you want to do is called Content Adaptation. There are
several ways to do it as summarized at
http://wiki.squid-cache.org/SquidFaq/ContentAdaptation

HTH,

Alex.
P.S. Squid may get a fresh copy from the origin server if you tell the
browser to refresh the page or if Squid decides to refresh it for other
reasons. Your refresh patterns may combat some of these problems. Please
note that the patterns you used did not reach this mailing list.


More information about the squid-users mailing list