Created
April 5, 2018 03:14
-
-
Save kaoru-fukusato/53f10ce623c8baf7c8f35dbcfdf8678c to your computer and use it in GitHub Desktop.
高速化対策 その5
This file contains 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
// ウェブサーバーが対応していれば、これらを.htaccessに入れておくだけで、とっても効果的 | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresDefault "access plus 2 weeks" | |
ExpiresByType image/gif "access plus 1 weeks" | |
ExpiresByType image/png "access plus 1 weeks" | |
ExpiresByType image/jpg "access plus 1 weeks" | |
ExpiresByType image/jpeg "access plus 1 weeks" | |
ExpiresByType text/html "access plus 1 seconds" | |
ExpiresByType text/css "access plus 2 weeks" | |
ExpiresByType text/javascript "access plus 2 weekss" | |
ExpiresByType application/x-javascript "access plus 2 weeks" | |
ExpiresByType font/opentype "access plus 2 weeks" | |
ExpiresByType font/ttf "access plus 2 weeks" | |
ExpiresByType font/eot "access plus 2 weeks" | |
ExpiresByType font/otf "access plus 2 weeks" | |
</IfModule> | |
// Apacheの.htaccessの設定方法 | |
// Leverage browser caching 対策 | |
<ifModule mod_expires.c> | |
ExpiresActive On | |
ExpiresByType image/jpg "access 3 days" | |
ExpiresByType image/jpeg "access 3 days" | |
ExpiresByType image/gif "access 3 days" | |
ExpiresByType image/png "access 3 days" | |
ExpiresByType text/css "access 1 month" | |
ExpiresByType text/html "access 1 month" | |
ExpiresByType application/pdf "access 1 month" | |
ExpiresByType text/x-javascript "access 1 month" | |
ExpiresByType application/x-shockwave-flash "access 1 month" | |
ExpiresByType image/x-icon "access 3 days" | |
ExpiresDefault "access 1 month" | |
</ifModule> | |
// Specify a Vary: Accept-Encoding header 対策 | |
<IfModule mod_headers.c> | |
<FilesMatch "\.(js|css|xml|gz)$"> | |
Header append Vary: Accept-Encoding | |
</FilesMatch> | |
</IfModule> | |
// Defer parsing of Javascript 対策 | |
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css|pdf)$"> | |
ExpiresActive On | |
ExpiresDefault A2592000 | |
</FilesMatch> | |
<ifmodule mod_deflate.c> | |
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript | |
</ifmodule> | |
// Enable Keep-Alive 対策 | |
<ifModule mod_headers.c> | |
Header set Connection keep-alive | |
</ifModule> | |
// Configure entity tags (ETags) 対策 | |
<Files ~ "\.(css|js|html?|xml|gz)$"> | |
FileETag MTime Size | |
</Files> | |
<Files ~ "\.(gif|jpe?g|png|flv|mp4|ico)$"> | |
FileETag None | |
</Files> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment