Expires and CDNS - YSlow Problems

前端 未结 1 959
长情又很酷
长情又很酷 2021-02-19 09:10

Let me first mention that I have done some digging but can\'t seem to find a proper answer to what I\'ll looking for.

I\'m working on a site where I am using a

相关标签:
1条回答
  • 2021-02-19 10:06

    Short answer:

    You can't control much when you're loading resources from external servers like that, but it may still be okay for your site. When using a tool like YSlow it's important to not get caught up into an "A" grade for everything. It's best to understand the hints the tool is giving you, and make decisions accordingly.

    Longer answers:

    Content Delivery Network

    YSlow will report lower grades for any domains it doesn't recognize as a CDN. You can add CDN hostnames, then it will reflect a better grade. I would add fonts.googleapis.com and ajax.googleapis.com because both behave like CDNs. Think of it as saving a preference in your copy of YSlow. Adding the domains here doesn't actually change your performance, it just improves your score.

    Expires Headers

    You can't control expires headers for content you're loading from a different site. Options you could consider:

    1. Continue using external sites; in this case these are pretty well behaved and your performance will probably be pretty good. Just ignore the low grade that YSlow is giving you.
    2. Host your fonts and jQuery files locally, then set far-futures expires headers as you've shown in your .htaccess. This would give you a better YSlow grade, but actual performance may be worse if your server is slower than the CDNs. (see this SO question)
    3. Use external sites but adjust your URL; in the case of jQuery, if you specify on more version level (1.8.0 instead of 1.8) you will get a far future expires header (see this SO question)
    0 讨论(0)
提交回复
热议问题