Sta*_*ski 5 .htaccess caching cache-control deflate font-awesome
我使用谷歌速度来优化我的网站,它告诉我放入很棒的缓存字体。
\n\n我的 htaccess 有以下代码,但它似乎没有将该文件放入缓存中:
\n\n# MOD_DEFLATE COMPRESSION\nSetOutputFilter DEFLATE\nAddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php\n#Pour les navigateurs incompatibles\nBrowserMatch ^Mozilla/4 gzip-only-text/html\nBrowserMatch ^Mozilla/4\\.0[678] no-gzip\nBrowserMatch \\bMSIE !no-gzip !gzip-only-text/html\nBrowserMatch \\bMSI[E] !no-gzip !gzip-only-text/html\n#ne pas mettre en cache si ces fichiers le sont d\xc3\xa9j\xc3\xa0\nSetEnvIfNoCase Request_URI \\.(?:gif|jpe?g|png)$ no-gzip\n#les proxies doivent donner le bon contenu\nHeader append Vary User-Agent env=!dont-vary\n\n# BEGIN Expire headers\n<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresDefault "access plus 1 year"\n ExpiresByType image/jpg "access plus 1 year"\n ExpiresByType image/jpeg "access plus 1 year"\n ExpiresByType image/png "access plus 1 year"\n ExpiresByType image/gif "access plus 1 year"\n AddType image/x-icon .ico\n ExpiresByType image/ico "access plus 1 year"\n ExpiresByType image/icon "access plus 1 year"\n ExpiresByType image/x-icon "access plus 1 year"\n ExpiresByType text/css "access plus 2592000 seconds"\n ExpiresByType text/javascript "access plus 2592000 seconds"\n ExpiresByType text/html "access plus 7200 seconds"\n ExpiresByType application/xhtml+xml "access plus 7200 seconds"\n ExpiresByType application/javascript A259200\n ExpiresByType application/x-javascript "access plus 2592000 seconds"\n ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"\n# Add a far future Expires header for fonts\nAddType application/vnd.ms-fontobject .eot \nAddType application/x-font-ttf .ttf\nAddType application/x-font-opentype .otf\nAddType application/x-font-woff .woff\nAddType image/svg+xml .svg\nExpiresByType application/vnd.ms-fontobject "access plus 1 year"\nExpiresByType application/x-font-ttf "access plus 1 year"\nExpiresByType application/x-font-opentype "access plus 1 year"\nExpiresByType application/x-font-woff "access plus 1 year"\nExpiresByType image/svg+xml "access plus 1 year"\n</IfModule>\n# END Expire headers\n\n# BEGIN Cache-Control Headers\n<IfModule mod_headers.c>\n <FilesMatch "\\\\.(ico|jpe?g|png|gif|swf|gz|ttf)$">\n Header set Cache-Control "max-age=2592000, public"\n </FilesMatch>\n <FilesMatch "\\\\.(css)$">\n Header set Cache-Control "max-age=2592000, public"\n </FilesMatch>\n <FilesMatch "\\\\.(js)$">\n Header set Cache-Control "max-age=2592000, private"\n </FilesMatch>\n<filesMatch "\\\\.(html|htm)$">\nHeader set Cache-Control "max-age=7200, public"\n</filesMatch>\n# Disable caching for scripts and other dynamic files\n<FilesMatch "\\.(pl|php|cgi|spl|scgi|fcgi)$">\nHeader unset Cache-Control\n</FilesMatch>\n</IfModule>\n# END Cache-Control Headers\n\n# KILL THEM ETAGS\nHeader unset ETag\nFileETag none\nRun Code Online (Sandbox Code Playgroud)\n\n任何形式的帮助将不胜感激。
\n如果您的服务器上确实有 fontawesome 字体,您可以将它们缓存在 .htaccess 文件中,如下所示;
<IfModule mod_expires.c>
Header set cache-control: public
ExpiresActive on
ExpiresByType font/ttf "access plus 1 month"
ExpiresByType font/woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>
<IfModule mod_deflate.c>
<FilesMatch "\.(ttf|otf|eot|svg)$" >
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12924 次 |
| 最近记录: |