本文介绍了YSlow的还是没有给我一个A在apache httpd的expires头,即使我加入他们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

努力的ExpiresDefault ExpiresByType这样一来会被缓存添加到内容在我的网站。我使用缓存无效化的URL(在路径中的版本号)为Javascript,CSS和图像这样一来,我可以将它设置为永远这些MIME类型。我在apache httpd的设置以下规则:

trying to add an ExpiresDefault ExpiresByType to content on my website so that way it is cached. I use cachebusting in the URL (a revision number in the path) for Javascript, CSS, and images so that way I can set it to forever for these mimetypes. I have the following rules set up in apache httpd:

  ExpiresActive On
  ExpiresDefault "access plus 1 minutes"
  ExpiresByType image/gif "access plus 10 years"
  ExpiresByType image/png "access plus 10 years"
  ExpiresByType image/jpeg "access plus 10 years"
  ExpiresByType image/jpg "access plus 10 years"
  ExpiresByType text/javascript "access plus 10 years"
  ExpiresByType text/css "access plus 10 years"

然后,当我去我的网站,并使用httplive头看看我的头得到了什么,我认为应该是正确的CSS过期:过期:孙老师,2019年2月3日17点52分48秒GMT

Then when I go to my website http://karmerd.com and use httplive headers to look at the headers I get what I think should be the correct Expires for css: Expires: Sun, 03 Feb 2019 17:52:48 GMT

但是我用雅虎的YSlow的Firebug扩展,它仍然给了我一个F不使用过期!难道我做错了什么?我还使用我的网站上gravatars,但他们已经过期时间设置。好像事事有过期。是不是YSlow的还是我?

But I use Yahoo's Yslow firebug extension and it's still giving me an F for not using Expires! Am I doing something wrong? I'm also using gravatars on my site, but they have Expires set. Seems like everything has an expires. Is it Yslow or me?

推荐答案

JavaScript文件被发送出去为应用程序/ x-的JavaScript ,所以都没有得到远的Expires头。

Your javascript files are being sent out as application/x-javascript, so aren't getting a far-future Expires header.

这篇关于YSlow的还是没有给我一个A在apache httpd的expires头,即使我加入他们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 15:35