Question

I can't send Etag header from my site

I'm not sure is it PHP or Nginx issue

but I can send a Last-Modified header

I discovered that I can do something like this to replace etag

// response
last-modified: 2929606074

// request
if-modified-since: 2929606074

should I use this way?

I also think another way is use the uniqid value (2929606074) minus current timestamp

like: 2929606074 - 1386929153 = 1542676921 and set it as last-modified date

// response
last-modified: Tue, 20 Nov 2018 01:22:01 GMT
Was it helpful?

Solution

No you should not. HTTP explicitly suggests to send both headers:

the preferred behavior for an HTTP/1.1 origin server is to send both a strong entity tag and a Last-Modified value.

ETag and Last-Modified have a very similar purpose, but the semantic is different. With ETag you identify an entity, with Last-Modified you identify the date of a resource with a resolution of 1 second. Also the client behaviour is different:

  • MUST use that entity tag
  • SHOULD use Last-Modified
  • SHOULD use both
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top