Last active
March 13, 2019 22:09
-
-
Save eduardinni/084f6835942b89e7e7459550c5b952d4 to your computer and use it in GitHub Desktop.
PageSpeed apache conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
# The ServerName directive sets the request scheme, hostname and port that | |
# the server uses to identify itself. This is used when creating | |
# redirection URLs. In the context of virtual hosts, the ServerName | |
# specifies what hostname must appear in the request's Host: header to | |
# match this virtual host. For the default virtual host (this file) this | |
# value is not decisive as it is used as a last resort host regardless. | |
# However, you must set it for any further virtual host explicitly. | |
#ServerName www.example.com | |
ServerAdmin webmaster@localhost | |
DocumentRoot /var/www/html | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresByType image/jpg "access 1 year" | |
ExpiresByType image/jpeg "access 1 year" | |
ExpiresByType image/gif "access 1 year" | |
ExpiresByType image/png "access 1 year" | |
ExpiresByType text/css "access 1 year" | |
ExpiresByType text/html "access 1 month" | |
ExpiresByType application/pdf "access 1 year" | |
ExpiresByType text/x-javascript "access 1 month" | |
ExpiresByType application/x-shockwave-flash "access 1 year" | |
ExpiresByType image/x-icon "access 1 year" | |
ExpiresDefault "access 1 year" | |
</IfModule> | |
<IfModule mod_headers.c> | |
Header set Connection keep-alive | |
<filesmatch "\.(ico|flv|gif|swf|eot|woff|woff2|otf|ttf|svg)$"> | |
Header set Cache-Control "max-age=31536000, public" | |
</filesmatch> | |
<filesmatch "\.(jpg|jpeg|png)$"> | |
Header set Cache-Control "max-age=31536000, public" | |
</filesmatch> | |
<filesmatch "\.(eot|woff|otf|ttf|svg)$"> | |
Header set Cache-Control "max-age=31536000, public" | |
</filesmatch> | |
# css and js should use private for proxy caching | |
# https://developers.google.com/speed/docs/best-practices/caching#LeverageProxyCaching | |
<filesmatch "\.(css)$"> | |
Header set Cache-Control "max-age=31536000, private" | |
</filesmatch> | |
<filesmatch "\.(js)$"> | |
Header set Cache-Control "max-age=31536000, private" | |
</filesmatch> | |
<filesMatch "\.(x?html?|php)$"> | |
Header set Cache-Control "max-age=600, private, must-revalidate" | |
</filesMatch> | |
</IfModule> | |
<IfModule mod_deflate.c> | |
<IfModule mod_filter.c> | |
# these are known to be safe with MSIE 6 | |
AddOutputFilterByType DEFLATE text/html text/plain text/xml | |
# everything else may cause problems with MSIE 6 | |
AddOutputFilterByType DEFLATE text/css | |
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript | |
AddOutputFilterByType DEFLATE application/rss+xml | |
AddOutputFilterByType DEFLATE application/xml | |
AddType image/svg+xml .svg | |
AddOutputFilterByType DEFLATE image/svg+xml | |
</IfModule> | |
</IfModule> | |
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn, | |
# error, crit, alert, emerg. | |
# It is also possible to configure the loglevel for particular | |
# modules, e.g. | |
#LogLevel info ssl:warn | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
# For most configuration files from conf-available/, which are | |
# enabled or disabled at a global level, it is possible to | |
# include a line for only one particular virtual host. For example the | |
# following line enables the CGI configuration for this host only | |
# after it has been globally disabled with "a2disconf". | |
#Include conf-available/serve-cgi-bin.conf | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment