Table of Contents

PFSense - Squid - Local Cache

Squid Cache General Settings

Cache Replacement PolicyHeap LFUDA
Low-Water Mark in %90
High-Water Mark in %95
Do Not Cache
steampowered.com
steamcommunity.com
steamgames.com
steamusercontent.com
steamcontent.com
steamstatic.com
Enable Offline ModeNot checked
External Cache Managers

Squid Hard Disk Cache Settings

Hard Disk Cache Size50000
Hard Disk Cache Systemaufs
Level 1 Directories64
Hard Disk Cache Location/var/squid/cache
Minimum Object Size0
Maximum Object Size1024

Squid Memory Cache Settings

Memory Cache Size3072
Maximum Object Size in RAM1024
Memory Replacement PolicyHeap GDSF

Dynamic and Update Content

Memory Replacement PolicyChecked
Custom refresh_patterns
# 1 year = 525600 mins, 1 month = 43800 mins, 1 week = 10080 min, 1 day = 1440 min
 
#Optional: dont cache wordpress admin panel
refresh_pattern (wp-admin)  0 0% 0
 
# All Files.
refresh_pattern -i \.(3gp|7z|ace|asx|avi|bin|inc|cab|dat|qt|deb|rpm|divx|dvr-ms)(\?|$) 43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i \.(rar|jar|gz|tgz|tar|bz2|iso|arj|lha|lzh|iop|nzp|pak|mar)(\?|$)    43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i \.(m1v|m2(v|p)|mo(d|v)|(x-|)flv)(\?|$)                              43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i \.(jp(e?g|e|2)|gif|pn[pg]|bm?|tiff?|ico|swf)(\?|$)                  43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i \.(mp(e?g|a|e|1|2|3|4)|mk(a|v)|ms(i|u|p))(\?|$)                     43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i \.(og(x|v|a|g)|rar|rm|r(a|p)m|snd|vob|wav|ac4)(\?|$)                43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i \.(pp(s|t)(x?)|wax|wm(a|v)|wmx|wpl|zip|cb(r|z|t))(\?|$)             43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i \.(woff|txt|exe|dll|dmg|webm)(\?|$)                                 43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i \.(pdf|rtf|xls(x?)|doc(x?))(\?|$)                                   43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i \.(css)(\?|$)                                                       10080  60% 43800  ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i \.(js)(\?|$)                                                        10080  60% 10080  ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload
 
refresh_pattern -i \.(html|htm)(\?|$) 1440  60% 10080 ignore-no-cache ignore-no-store ignore-private override-expire reload-into-ims
#refresh_pattern -i \.(doc|pdf)(\?|$)  10080 90% 43200 ignore-no-cache ignore-no-store ignore-private override-expire reload-into-ims
 
refresh_pattern -i \.(cdn) 10800 100% 43800 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-private
refresh_pattern -i (cdn)   10800 100% 43800 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-private
 
 
refresh_pattern \.ytimg\? 10800 90% 10800 override-expire ignore-reload ignore-no-cache
refresh_pattern ^http://*.facebook.com/* 720 100% 4320
refresh_pattern ^http://*.yahoo.*/.* 720 100% 4320
refresh_pattern ^http://*.yimg.*/.* 720 100% 4320
refresh_pattern ^http://*.gmail.*/.* 720 100% 4320
refresh_pattern ^http://*.google.*/.* 720 100% 4320
refresh_pattern ^http://*.googlesyndication.*/.* 720 100% 4320
refresh_pattern ^http://*.apple.*/.* 720 100% 4320
 
refresh_pattern ^ftp:  1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440

# Dynamic Content.
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
 
# Catch all.
#refresh_pattern . 360 90% 1440 override-lastmod reload-into-ims
refresh_pattern . 0 20% 4320

cache_mem

This is one of the top two options as far as performance impact goes.

The default value here is 8 MB, which is a safe option for just about any system size.

But since your box is not lacking in memory it can safely be raised to 32 MB, and even 48 if you have stripped all other services off of your server.

If your box is lacking in memory, go back to the hardware section and reread the part about memory…you need a bunch of memory for a fast web cache.

You should be aware that cache_mem does not limit the process size of squid. This sets how much memory squid is allowed to set aside for “hot objects” which are the most recently used objects.

Having said all that, keep in mind that the buffer cache in Linux is also quite good, so the gains you'll see by raising this are very small, but still measurable.


cache_dir

This is where you set the directories you will be using.

You should have already mkreiserfs'd your cache directory partitions, so you'll have an easy time deciding the values here.

First, you will want to use about 80% or less of each cache directory for the web cache.

If you use any more than that you will begin to see a slight degradation in performance.

Remember that cache size is not as important as cache speed, since for maximum effectiveness your cache needs only store about a weeks worth of traffic.

You'll also need to define the number of directories and sub-directories. The formula for deciding that is this:

x=Size of cache dir in KB (i.e. 6GB=~6,000,000KB) 
y=Average object size (just use 13KB)
z=Number of directories per first level directory (((x / y) / 256) / 256) * 2 = # of directories

As an example, if 6GB of the drives is used, so:

6,000,000 / 13 = 461538.5 / 256 = 1802.9 / 256 = 7 * 2 = 14

So my cache_dir line would look like this: cache_dir 6000 14 256