Skip to content

Instantly share code, notes, and snippets.

@crazyyy
Last active January 31, 2022 12:58
Show Gist options
  • Save crazyyy/17f361709a1c78e45e0ab6725f8d02f0 to your computer and use it in GitHub Desktop.
Save crazyyy/17f361709a1c78e45e0ab6725f8d02f0 to your computer and use it in GitHub Desktop.
htaccess

.htaccess

TODO

links

Disable Etags:

Header unset ETag
FileETag None

Add expire headers:

<FilesMatch "\.(ico|jpg|jpeg|png|gif|webp|js|css|swf)$">
  Header set Expires "Tue, 16 Jun 2020 20:00:00 GMT"
</FilesMatch>
# Or
ExpiresActive On
ExpiresByType text/html "access plus 1 day"
ExpiresByType image/gif "access plus 10 years"
ExpiresByType image/jpeg "access plus 10 years"
ExpiresByType image/png "access plus 10 years"
ExpiresByType text/css "access plus 10 years"
ExpiresByType text/javascript "access plus 10 years"
ExpiresByType application/x-javascript "access plus 10 years"

Compress plain text file:

<FilesMatch "\.(js|css|html|htm|php|xml)$">
  SetOutputFilter DEFLATE
</FilesMatch>

GZip compression

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css  application/x-javascript
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

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