Apache allows us to improve the caching of our resources. We need mod_expires and mod_headers. They must be loaded in (where?)
LoadModule expires_module libexec/mod_expires.so
LoadModule hearders_module libexec/mod_headers.so
AddModule mod_expires.c
AddModule mod_headers.c
AddModule mod_gzip.c
Note that mod_gzip must be loaded last.
AddModule mod_headers.c
AddModule mod_gzip.c
Note that mod_gzip must be loaded last.
To turn on mod_expires set:
ExpiresActive On
Then on the root directory:
AllowOverride none
Order allow, deny
Allow from all
ExpiresDefault A300
# Not rely on file extensions
#
#
ExpireActive On
ExpiresDefault "access plus 300 seconds"
Options FollowSymLunks Multiviews
AllowOverride All
Order allow, deny
Allow from all
ExpiresByType text/html "access plus 1 day"
ExpiresByType text/css "access plus 1 day"
ExpiresByType text/javascript "access plus 1 day"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 day"
# We can minimize the response sent by setting
ServerTokens Min
Our images are now cachable for 30 days. However the HTML file does not have a Last-Modified header. This is because we use conditional server-side includes to merge in different CSS for different browsers to save a HTTP request. We'll address the cachability of SSI pages in a future tweak.
# The HTML file does not have a Last-Modified header. This is because we use
# conditional server-side includes to merge in different CSS for different
# browsers to save a HTTP request. We'll address the cachability of SSI pages in a future tweak.