Skip to content

Two 200 before the 304 #138

@nitriques

Description

@nitriques

When fetching an external image, jit now issues 2 HTTP 200 responses before sending the 304. Here's why:

  1. The modified time and etag are calculated with a 2nd http request to get the headers (I wonder why, more on that later)
  2. I've added things to use the filemtime of the cache file, which then creates new last modified and etag (so our logic fails)
  3. You then get a proper 304.

I wanted to be able to server the cache from the external server #130 and #136

The two request are shaped like this:

  1. The first one requests the whole file, skipping the headers
  2. The second one only request the headers. Based on libcurl's documentation, doing so sends a HEAD http request and should (if the remote server's smart enough) only sends headers...

I can't seem to figure out how we can get rid of one or the other, but I think we should never do both, as it's the way right now. Should we:

  1. Do the HEAD request always, to make sure the cache is valid ? What about servers that do not return cache headers ?
  2. Store this info in the DB, to be able to regenerate the original etag ?
  3. Give up ? I mean, this behavior occurs only for the first person to hit the url, since all others will get the cache and never see the original response ?
  4. Change our we cache external images ?

The more I think about it, the more I want performance. The simplest thing would be to number 4 including the following:

  1. Never cache external images that do not send proper cache headers ? See Proposition: Never cache external images that do not send proper cache headers #139
  2. Always respond with the cache file's mtime and etag and hide the one from the origin ?
  3. Randomly poke the remote server to validate the cache ?

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions