Alister West

home is where your code is ...

Apache Cache-Control

With appropriate Cache-Control headers caching proxies (like Varnish) we can deliver cached content from nodes (i.e. to make an easysetup CDN).

# Apache Location block for sensible caching
<Location />

    # Cache everything by default.
    Header Set Cache-Control "Public, max-age=3600"

    # Don't cache with session
    SetEnvIf Cookie "[ ]?s=" loggedin=1
    Header Set Cache-Control "Private" env=loggedin

    # Don't cache POSTs
    SetEnvIf Request_Method "^POST" posted=1
    Header Set Cache-Control "no-cache" env=posted


<Location /static>
    # Cache static content for 1 year
    Header set Cache-Control "Public, max-age=31536000"

# /static/js/site-32.min.js => /static/js/site.min.js
# /static/css/site-32.min.css => /static/css/site.min.css
# - PT|Passthrough (implies L) passes the uri through to Alias/ScriptAlias rules.
#   Necessary if used in conjunction with a dynamic site like:
#       "ScriptAlias / /home/alister/mysite/script/"

RewriteEngine on
RewriteRule ^/(static/.*)/site-[0-9]+\.min\.(css|js) /$1/site.min.$2 [PT]
By Alister West