-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ETag/If-None-Match doesn't work as expected on production #92
Comments
Found the reason and possible fixes. If the client sends the header One possible solution is to avoid sending Another solution is to make compression on the upstream side with To see how it works, request this url twice from the browser:
The second request should return PR is coming. |
May I please take a look on your nginx config, I am struggling configuring if-none-match. I am new to this so it would be really helpful if I can compare the proxy_cache_key config part. Thank you |
swapi.co doesn't return 304 (Not Modified) on subsequent requests with
If-None-Match
request header set to the same value as ETag from the server responseSteps to reproduce (Chrome)
Make sure that cache is not disabled in dev tools. Request the following url twice directly from the browser:
http://swapi.co/api/?format=json
, or executefetch('http://swapi.co/api/?format=json')
from console.The first response from the server would have
ETag
header like this:The second request to the server would have
If-None-Match
header with the same checksum:It is expected that the second response would have status code 304 (Not Modified) with empty body, since the checksum hasn't changed. But the actual status code is 200 with the same body as the first request's.
Dev environment
The thing is, it works as expected in dev environment, given that it's being served over HTTP/1.1.
Possible reasons
The first notable difference between prod and dev is that prod responds with weak ETag in the form
W/"<string>"
. It might have something to do with cloudflare, since they support ETag. I haven't investigated that further though.That I am sure about is that it has to do with weak ETags. Try to make the second request, mentioned above, through curl:
outputs
Then try to manually remove
W/
part from the checksum:outputs
It would be nice to have it working!
The text was updated successfully, but these errors were encountered: