npm / registry-issue-archive

An archive of the old npm registry issue tracker
https://npm.community
249 stars 47 forks source link

Packuments should Vary on Accept header #190

Closed iarna closed 7 years ago

iarna commented 7 years ago

The Vary header is currently set to Accept-Encoding and I believe it needs to be Accept-Encoding, Accept because we do vary content on the basis of the Accept header (when deciding to serve corgis or not.)

soldair commented 7 years ago

this has been deployed =) we may have to slowly purge all of the documents as headers aren't refreshed if we 304 on the backend response from the cache miss.

iarna commented 7 years ago

@soldair I'm still not seeing it:

$ lwp-request -dE https://registry.npmjs.org/npm
GET https://registry.npmjs.org/npm
User-Agent: lwp-request/6.15 libwww-perl/6.15

200 OK
Cache-Control: max-age=300
Connection: close
Date: Sat, 08 Jul 2017 22:43:48 GMT
Via: 1.1 varnish
Accept-Ranges: bytes
ETag: "595d9b1f-646cda"
Server: nginx/1.10.1
Vary: Accept-Encoding
Content-Length: 6581466
Content-Type: application/json
Last-Modified: Thu, 06 Jul 2017 02:06:23 GMT
Client-Date: Sat, 08 Jul 2017 22:43:47 GMT
Client-Peer: 151.101.40.162:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=BE/O=GlobalSign nv-sa/CN=GlobalSign Extended Validation CA - SHA256 - G2
Client-SSL-Cert-Subject: /businessCategory=Private Organization/serialNumber=5452409/jurisdictionC=US/jurisdictionST=Delaware/C=US/ST=California/L=Oakland/street=1999 Harrison Street Suite 1150/O=npm, Inc./CN=npmjs.org
Client-SSL-Cipher: ECDHE-RSA-AES128-GCM-SHA256
Client-SSL-Socket-Class: IO::Socket::SSL
X-Cache: HIT
X-Cache-Hits: 0
X-Served-By: cache-sjc3635-SJC
X-Timer: S1499553828.412598,VS0,VE23

Vary: Accept-Encoding

So I'm assuming this is due to the need to cache purge?

Ah yeah, I do see it for cache misses.

So yeah, this won't be useful to us until the cache is refreshed.

iarna commented 7 years ago

Everything looks good now!