How to force a web browser to cache Images

后端 未结 3 1813
梦谈多话
梦谈多话 2020-12-03 01:14

I am writing a small application which serves images from the local computer, so they can be accessed as http://localhost:12345/something/something (which returns a jpeg). <

相关标签:
3条回答
  • 2020-12-03 01:35

    You can't and nor should you - this is the user's decision to make not yours.

    What you can do is strongly suggest with the right headers, but even then you should expect t deal with a number of HEAD requests ever after.

    0 讨论(0)
  • 2020-12-03 01:44

    try the expires http header: http://en.wikipedia.org/wiki/List_of_HTTP_headers

    You probably have to merge this with your cache-control

    0 讨论(0)
  • 2020-12-03 01:46

    A Last-Modified and Expires header might also be useful additions.

    Your server should also check for requests featuring an If-Modified-Since header, and return a 304 Not Modified response if possible to speed things along.

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