Removing individual objects from Squid cache
In some circumstances, you may find it necessary to manually remove one or more objects from Squid's cache. This might occur if:
- One of your users complains about always receiving a stale data.
- You want to remove some large objects to free up room for new data.
- Squid was caching responses from local servers, and you don't want it to.
Often these problems can be solved by forcing a reload in a web browser, typically this can be performed by holding the Shift key and pressing the reload/refresh button. However, this doesn't always work. For example, some browsers display certain content types externally by launching another program; that program probably doesn't have a reload/refresh button or even know about caches.
Using a simple squidclient command, individual URLs can be removed from Squid's cache. However, Squid disables this functionality by default so several lines must be added to the Squid configuration file template before this command will work.
WARNING: the following instructions assume competence and experience with navigating the Linux command line and editing text files therein. If you are not confident that you can complete these steps successfully, please contact our Support staff who will be able to assist you.
To enable PURGE requests in Squid, several lines must be added to the Squid configuration file template and subsequently written out to the Squid configuration file:
- Login to the Getbusi server as root.
- Open up the Squid conf template with a text editor:
- Below the line that reads acl manager pro to cache_object add the new line acl Purge method PURGE
- Below the line that reads http_access allow manager localhost add the new line http_access allow localhost Purge
- Below the line that reads http_access deny manager add the new line http_access deny Purge
- Write the changes to disk and quit the text editor.
- Reconfigure Getbusi to write the Squid conf template to the Squid conf file:
- Restart the Squid service:
service squid restart
You may now use the following command to purge individual URLs from the Squid cache:
squidclient -m PURGE http://www.example.org/junk
If the object is successfully purged it will respond withHTTP/1.0 200 OK, if the specified URI is not present in the cache the response will beHTTP/1.0 404 Not Found.