Installing Squid - What needs to be done?


(Nic Hubbard) #1

Matrix Version: 5.4.3.1

We are looking to install Squid to hopefully speed up some of the pages on our website. We use Ubuntu, so besides installing and configuring the package for Squid, what configuration needs to be done in Matrix in order to start using Squid? Is there any documentation for this?


(Byrne) #2

Squid can be setup in a few ways to add the caching proxy that you are looking for.
The exact setup will be based on your own system needs. As a rev proxy Squid is fairly independent of Matrix and only has 2 main interactions.

  1. Clearing the cache
    https://matrix.squiz.net/manuals/system-configuration/chapters/external-tools-configuration#Squid-Cache
    You’ll want to configure Matrix to hit the correct port to allow the application to purge a URL stored in Squid.

  2. Headers
    Squid should always respect the cache-contorl header, eg. ignoring private headers, revalidating after the max-age or expires has passed. Matrix will need to be configure to default send the correct headers
    https://matrix.squiz.net/manuals/system-management/chapters/cache-manager#Send-Cacheable-Header-Screen
    The root node and type code cache settings simply override or control the headers sent.

Lastly if your debugging check you headers in the first instance.
Reviewing the headers returned from a curl on 127.0.0.1:80 can provide information that caching proxies can sometimes choose to override or exclude. Keeping in mind the default config should allow headers to passthrough seamlessly so other upstream proxies follow the same page rules.


(Ben Freke) #3

Hi Nic

Another configuration setting to check is SQ_CONF_USE_HTTP_X_FORWARDED_FOR


(Ben Freke) #4

And some other useful config for your squid.conf file.

# use this if you have a single squid in front of a single Matrix to avoid burying your backend if it's already struggling
retry_on_error off

# This block avoids caching backend related content
acl QUERY urlpath_regex /_edit /_admin /_login /_nocache /_recache /_performance /__lib /__fudge
acl POST method POST
cache deny QUERY
cache deny POST

# if the site experiences high traffic this will be required
# see also "ulimit -n <number of file descriptors>"
max_filedesc 8192

# To ensure we honour cache headers on 404s from Matrix we need to ensure there is
# some positive value in negative_ttl, as long as there is, Squid honours the
# timings set by Matrix.
negative_ttl 1 second

(Nic Hubbard) #5

Thank you very much!!