No Cache Option

July 18, 2011 • Customer Services       
Synopsis

The CensorNet runs the Squid caching server as part of its services. This means that it tends to cache sites so that it can serve a frequently visited site more quickly. On ocassion, you may wish to cause the CensorNet to not cache a particular page or site. This article explains how.

Article

It can sometimes be useful to stop a site, or just a specific URL from being cached. In order to achieve this you need to edit a few files.

Log into the CensorNet's command line as root and type these commands

cd /etc/squid
nano squid.conf

Now that you are editing the file press and release the Esc key followed by the / key - this should put your cursor at the end of the file.

Type the following lines in order.

acl NOCACHE_DOMAIN dstdomain "/etc/squid/nocache_domain"
acl NOCACHE_REGEX url_regex "/etc/squid/nocache_url_regex"
cache deny NOCACHE_DOMAIN
cache deny NOCACHE_REGEX

Press Ctrl-O RETURN to write the file
Press Ctrl-X to exit the editor

Now type these commands

touch nocache_domain
touch nocache_url_regex

The will have created two files, which are both currently empty.

You can now add domains to the nocache_domain file. For example, to tell the system not to cache anything from bbc.co.uk you can type the following :-

nano nocache_domain
.bbc.co.uk

Ctrl-O RETURN
Ctrl-X

Notice the leading full stop in the line for the domain. This is important, and now any subdomains ending in bbc.co.uk will be non-cached.

If you just wanted to stop the CensorNet from caching some content from the domain, you could, for instance type these commands (note the use of the other file) :-

nano nocache_url_regex
http://bbc.co.uk/games/*

Ctrl-O RETURN
Ctrl-X

This will ensure that only pages from the games section of the bbc site are non-cached, other content will continue to be cached.

Finally, remember to type this command.

/etc/init.d/squid reload

This ensures that the Squid re-reads its configuration files.

Related articles


Last modified on Mon, July 18, 2011 « Back