Caching from URLs with a query string

后端 未结 2 1566
星月不相逢
星月不相逢 2020-12-11 17:30

The web application I\'m working on serves up images with URLs like /image?name=a.gif. Pages are loading slowly partly because browsers are not caching the images.

I

相关标签:
2条回答
  • 2020-12-11 17:50

    Set the expires header in your web server to some far away date.

    0 讨论(0)
  • 2020-12-11 18:00

    It's commonly thought that a lot of older browsers (including IE6) and some older versions of caches like Squid won't cache any file that has a querystring attached, regardless of the expires date.

    The more robust alternative to querystring versioning is to put versioning information into the path, such as:

    site/static/23212903/css/bundle.css
    

    Or:

    site/images/logo.r23212903.png
    

    For more, here's a great article on setting cache headers correctly by Sergey Chernyshev.

    0 讨论(0)
提交回复
热议问题