如何加快网络开发与正确的Apache缓存头设置? [英] How to speed up web development with correct Apache caching headers setup?
问题描述
亲爱的乡亲,结果
尽管有种种措施注释,以在htaccess文件设置正确的缓存code,我仍然得到这个错误:
的指定缓存验证的:
所有的静态资源应该有任何一个Last-Modified或ETag头。这将允许浏览器利用高速缓存的全部优势。
块引用>
这有什么错我的htaccess的缓存设置?如果您对这些设置的改进,我会很高兴地听到。非常感谢您的建议。
< IfModule mod_headers.c>
头未设置杂注
FileETag无
头取消设置的ETag
ExpiresActive On配置 #####动态页面
< FilesMatch\\\\(AST | PHP | CSS)$。>
头设置缓存控制公,最大年龄= 3600,必重新验证
< / FilesMatch> #####静态文件
< FilesMatch\\\\(PNG | SVG | SWF | JS | XML)$。>
头设置缓存控制公,最大年龄= 604800,必重新验证
头取消设置的Last-Modified
< / FilesMatch>##### ETERNAL FILES
< FilesMatch\\\\(ICO | JPG | GIF | TTF | EOT | PDF | FLV)$。>
头中设置缓存控制公,最大年龄= 7257600,必重新验证
头取消设置的Last-Modified
< / FilesMatch>
< / IfModule>
解决方案您是专门取消设置Last-Modified头。这就是缓存验证部分。除去那些包含行:
头取消设置的Last-Modified
此外,为你的CSS真正的动态? CSS是巨大的很多网站。尝试缓存就像任何其他静态内容。
Dear folks,
Despite various measure ments to setup correct caching code in htaccess file, I still get this error:Specify a cache validator: All static resources should have either a Last-Modified or ETag header. This will allow browsers to take advantage of the full benefits of caching.
Is there anything wrong with my htaccess caching settings? If you have improvements for these settings i will be very happy to hear. Thank you very much for your suggestions.
<IfModule mod_headers.c> Header unset Pragma FileETag None Header unset ETag ExpiresActive On ##### DYNAMIC PAGES <FilesMatch "\\.(ast|php|css)$"> Header set Cache-Control "public, max-age=3600, must-revalidate" </FilesMatch> ##### STATIC FILES <FilesMatch "\\.(png|svg|swf|js|xml)$"> Header set Cache-Control "public, max-age=604800, must-revalidate" Header unset Last-Modified </FilesMatch> ##### ETERNAL FILES <FilesMatch "\\.(ico|jpg|gif|ttf|eot|pdf|flv)$"> Header set Cache-Control "public, max-age=7257600, must-revalidate" Header unset Last-Modified </FilesMatch> </IfModule>
解决方案You are specifically unsetting the Last-Modified header. That's the cache validator section. Remove those lines that include:
Header unset Last-Modified
Also, is your css really dynamic? CSS can be huge for a lot of websites. Try to cache that just like any other static content.
这篇关于如何加快网络开发与正确的Apache缓存头设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!