Open main menu

UESPWiki β

UESPWiki:Squid Setup

< UESPWiki

In January 2008 the site added its first Squid cache server to reduce the load on the primary and only content server. This page explains the steps necessarily to setupand maintain such a server.

Squid ConfigurationEdit

The relevant settings for Squid 2.6 are as follows:

squid.confEdit

      # A transparent cache on port 80 with virtual host name support
  http_port 80 defaultsite=uesp.net vhost
  
      # The one cache source, content1.uesp.net
  cache_peer 72.55.146.206 parent 80 0
  
      # Allow anyone to access the cache
  acl validdst dstdomain .uesp.net
  http_access allow validdst 
  
      # Allow the source and localhost to purge the cache
  acl content1 src 72.55.146.206
  http_access allow purge localhost
  http_access allow purge content1
  http_access deny purge
  
      # This must come after the previous lines
  http_access deny all
  
      # Rotate logfiles daily and keep up to 10 days
  logfile_rotate 10


cachemgr.confEdit

To allow the cache manager to access the Squid cache only one line is needed:

  localhost:80


Apache ConfigEdit

To access the Squid cache manager via the web Apache, or a similar web server, must be properly configured. Since this is not meant to be used publically only a minimal web server is needed. The following is for Apache v2.2.

     # The Squid cache is on port 80 so choose another unused port
  Listen 81
  ServerName squid1.uesp.net:81
  
     # Only allow a few potential clients to minimize RAM/CPU use
  StartServers    1
  MinSpareServers 1
  MaxSpareServers 3
  ServerLimit     3
  MaxClients      3
  
     # Allow access to the Squid cache manager
  ScriptAlias /Squid/cgi-bin/cachemgr.cgi /usr/lib/squid/cachemgr.cgi
  
     # Password protect access to the cache manager
  <Location /Squid/cgi-bin/cachemgr.cgi>
     AuthUserFile /etc/apacheauth
     AuthGroupFile /dev/null
     AuthName "User/Password Required"
     AuthType Basic
     require user cachemanager
  
          # Optionally limit access from only certain IPs/domains
     order allow,deny
     allow from someplace.com
  </Location>


MediaWiki ConfigurationEdit

LocalSettings.phpEdit

     # Enable use of the Squid cache
  $wgUseSquid = true;
  
     # Set the list of caches for purging purposes
  $wgSquidServers = array("72.55.137.132");


TestingEdit

Load up FireBug or a similar utility capable of viewing HTML request/response headers. Load up a page as an anonymous user (not logged in) and look for the following lines in the request header:

  Cache-Control  s-maxage=18000, must-revalidate, max-age=0
  X-Cache        MISS from cl-t021-251cl.privatedns.com
  X-Cache-Lookup MISS from cl-t021-251cl.privatedns.com:80

The s-maxage parameter tells the cache how long to cache the page and the default can be changed if desired in LocalSettings.php. A MISS indicates the file was not loaded from the cache while a HIT indicates that it was.

You can view the average cache hit rate by logging into the cache manager and viewing the Cache Utilization entry. The parameters of most interest are:

  client_http.requests = 46.309993/sec
  client_http.hits = 22.639997/sec

This indicates that almost half of all requests are being successfully served from the cache.

ReferencesEdit