Skip to content

Instantly share code, notes, and snippets.

@fillipetech
Created July 17, 2018 18:32
Show Gist options
  • Select an option

  • Save fillipetech/f35fc45021af6dfa0ef24111539bdad8 to your computer and use it in GitHub Desktop.

Select an option

Save fillipetech/f35fc45021af6dfa0ef24111539bdad8 to your computer and use it in GitHub Desktop.
Compress and Change expiration time #htaccess #performance

EXPIRES HEADER CACHING

insert filter by type (MIME)

AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/atom_xml AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-httpd-php AddOutputFilterByType DEFLATE application/x-httpd-fastphp AddOutputFilterByType DEFLATE application/x-httpd-eruby AddOutputFilterByType DEFLATE text/html SetOutputFilter DEFLATE

Ensures that some older browsers will not have compression because they do not support

BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

Não comprime imagens, pois a maioria já se encontra compactada, apresentando pouca ou nenhuma mudança

SetEnvIfNoCase Request_URI
.(?:gif|jpe?g|png)$ no-gzip dont-vary

EXPIRES HEADER CACHING

# Fonts # Add correct content-type for fonts AddType application/vnd.ms-fontobject .eot AddType application/x-font-ttf .ttf AddType application/x-font-opentype .otf AddType application/x-font-woff .woff AddType image/svg+xml .svg

Compress compressible fonts

only uncomment if you dont have compression turned on already. Otherwise it will cause all other filestypes not to get compressed

AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml

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 month" ExpiresByType application/pdf "access 1 month" ExpiresByType application/javascript "access 1 month" ExpiresByType application/x-javascript "access 1 month" ExpiresByType application/x-shockwave-flash "access 1 month" ExpiresByType image/x-icon "access 1 year"

Add a far future Expires header for fonts

ExpiresByType application/vnd.ms-fontobject "access plus 1 year" ExpiresByType application/x-font-ttf "access plus 1 year" ExpiresByType application/x-font-opentype "access plus 1 year" ExpiresByType application/x-font-woff "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year"

ExpiresDefault "access 2 days"

EXPIRES HEADER CACHING

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment