Quantcast
Viewing all articles
Browse latest Browse all 11

Answer by djeendo for Stop browser to make HTTP requests for images that should stay cached - mod_expires

If it is a matter of life or death (If you want to optimise page loading this way or if you want to reduce the load on the server as much as possible no matter what), then there IS a workaround.

Use HTML5 local storage to cache images after they were requested for the first time.

  • [+] You can prevent browser from sending HTTP requests, which in 99% would return 304 (Not Modified), no matter how hard user tries (F5, ctrl+F5, simply revisiting page, etc.)

  • [-] You have to put some extra efforts in javascript support for this.

  • [-] Images are stored in base64 (we cannot store binary data), thats why they are decoded each time at client side. Which is usually pretty fast and not big deal, but it is still some extra cpu usage at client side and should be kept in mind.

  • [-] Local storage is limited. You can aim at using ~5mb of data per domain (Note: base64 adds ~30% to original size of image).

  • [?] Supported by majority of browsers. http://caniuse.com/#search=localstorage

Example

Test


Viewing all articles
Browse latest Browse all 11

Trending Articles