How to purge bad cache from SQUID

If you’re using Squid Cache Proxy as your own proxy server, maybe you’ve experience Squid always returning the old cache even if the website itself already changed. If that’s the case then the only solution is by Purging the old cache from Squid cache. And there’s two method to do this. The first method is by deleting all of your squid cache but this would cause all of your cache lost and i don’t think you want that happen, right ? But don’t worry there’s other alternative and that’s by using PURGE command on squid.

As a side note this is for Windows user who use Squid as their cache proxy, most Linux users already know about this ;) .. okay here’s the step. First thing is open the squid.conf in your squid configuration directory, for example C:\Squid\etc\squid.conf and add these lines if it’s not already there.

acl PURGE method PURGE
http_access allow PURGE localhost
http_access deny PURGE

After adding these lines you can restart your squid service manually or you can just type below line from the command prompt

x:\squid\sbin\squid.exe -n Squid -f x:\squid\etc\squid.conf -k reconfigure

Where X is the path to the squid executable, to force reconfiguring squid without the need to restart squid service. And to purge the cache, you can simply type this :

X:\squid\bin\squidclient.exe -h 127.0.0.1 -m PURGE http://www.yourtargetwebsite.com/

The -h parameter, it’s not required if you run squid from localhost and don’t forget to replace the target website with the any website you want squid to purge from it’s cache also remember to add the last trailing slash, because it’s important or squid will return object not found like below :

HTTP/1.0 404 Not Found
Server: squid
Date: Sun, 17 Sep 2006 03:44:22 GMT
Content-Length: 0

And if you do it correctly Squid will return HTTP 200 OK like below :

HTTP/1.0 200 OK
Server: squid
Date: Sun, 17 Sep 2006 03:44:43 GMT
Content-Length: 0

Ok that’s all about it … hopefully it’ll help you to fix your problem with your squid cache ;)

Comment?

Note: Comment may not appear right away.

One comment on “How to purge bad cache from SQUID

  1. How would you remove a specific file, such as a JPG? I’ve tried above method, but it simply says “Object not found”. Tried with or without trailing ‘/’ – doesn’t want to work.

    Thx!