1

This is not a "coding question", but more something like "how does it work?".

Let's consider I want to show an heavy pic on page 2. If I'm preloading this pic on a page 1 (no display) and click on the page-2-link before it's fully loaded... What happens?

=> The page 2 loads and the end of heavy pic is also loaded, or cache doesn't work for partially loaded files?

Thanks for your explanations,

CH

CHA
  • 21
  • 3

1 Answers1

0

In theory its very possible that part of the response gets cached, either by the web browser or by a proxy server between the end user and the web server. http supports range requests, where the client can ask for a specific slice of the total resource(like an image). All the big name web servers support range requests.

I really don't know off hand if any web browsers cache a partially downloaded resource, although it would be a simple test - clear the web browsers cache, hit a web page that loads a large external object, stop loading midway through. Make sure the webserver sends the following headers along with the response.

cache-control: max-age=10000
accept-ranges: bytes

Now make the request again but look at the http headers of the request to look for the browser asking for partial contents like Range: bytes=100000-90000000. It would obviously only ask for partial content if it had partially cached the file.

The max-age header tells the browser the file is cachable for a while, and the accept-ranges headers tells the browser the web server is capable of servicing partial content requests.

goat
  • 31,486
  • 7
  • 73
  • 96