Created
October 29, 2015 07:19
-
-
Save nawawi/387ebc0fe62ecba3ebdc to your computer and use it in GitHub Desktop.
cache sample
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
| <IfModule mod_headers.c> | |
| #Header set X-Frame-Options sameorigin | |
| Header set X-Content-Type-Options nosniff | |
| Header set X-XSS-Protection '1; mode=block' | |
| Header set X-Permitted-Cross-Domain-Policies 'master-only' | |
| Header set Content-Security-Policy 'report-uri /csp_report_parser;' | |
| #Header set Cache-Control 'no-cache, no-store, must-revalidate' | |
| #Header set Pragma 'no-cache' | |
| #Header set Expires '-1' | |
| Header set Cache-Control 'public, max-age=2592000' | |
| #Header always edit Set-Cookie ^(.*)$ '$1;secure; httponly;' | |
| #Header always edit Set-Cookie "(?i)^((?:(?!;\s?HttpOnly).)+)$" "$1; secure; httponly" | |
| Header unset X-Powered-By | |
| Header unset X-Pingback | |
| Header unset P3P | |
| </IfModule> | |
| <IfModule mod_expires.c> | |
| # Enable expirations. | |
| ExpiresActive On | |
| # Cache all files for 2 weeks after modification (A). | |
| ExpiresDefault M1209600 | |
| <FilesMatch \.php$> | |
| # Do not allow PHP scripts to be cached unless they explicitly send cache | |
| # headers themselves | |
| ExpiresActive Off | |
| </FilesMatch> | |
| #Set caching on image files for 11 months | |
| <filesMatch "\.(ico|gif|jpg|png)$"> | |
| ExpiresDefault "modification plus 11 months" | |
| </filesMatch> | |
| <filesMatch "\.(css|js)$"> | |
| ExpiresDefault "modification plus 11 months" | |
| </filesMatch> | |
| ExpiresByType image/* "modification plus 11 months" | |
| ExpiresByType text/javascript "modification plus 11 months" | |
| ExpiresByType application/javascript "modification plus 11 months" | |
| ExpiresByType text/css "modification plus 11 months" | |
| # 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" | |
| </IfModule> | |
| AddType application/font-woff .woff | |
| AddType application/font-woff .woff2 | |
| AddType application/x-font-opentype .otf | |
| AddType application/x-font-ttf .ttf | |
| AddType image/vnd.microsoft.icon .cur |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment