Skip to content
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

If-None-Match header is ignored on POST requests #62

Open
iblue opened this issue May 1, 2012 · 7 comments
Open

If-None-Match header is ignored on POST requests #62

iblue opened this issue May 1, 2012 · 7 comments

Comments

@iblue
Copy link

iblue commented May 1, 2012

The title says everything. When I send a GET request to the server, containing an If-None-Match header that matches the ETag, I get a 304 Not Modified response as expected. When I do the same for POST-Requests, I get a full response, even though it has the given ETag.

iblue@raven ~ $ curl "http://testing.example.org/resource.json" -H 'If-None-Match: "11263794d27103747aa3048b8d1ca76d" ' -i
HTTP/1.1 304 Not Modified
Server: nginx/0.7.67
Date: Tue, 01 May 2012 12:33:23 GMT
Connection: keep-alive
Status: 304 Not Modified
X-UA-Compatible: IE=Edge,chrome=1
ETag: "11263794d27103747aa3048b8d1ca76d"
Cache-Control: must-revalidate, private, max-age=0
Set-Cookie: _session_id=82d7a4d488e4bd295902cca2b0e3f0b6; path=/; expires=Wed, 01-May-2013 12:33:23 GMT; HttpOnly
X-Request-Id: 4fc3e3bc9f7cd4c334d815ff6958d2d3
X-Runtime: 0.950690
X-Rack-Cache: miss
iblue@raven ~ $ curl -X POST "http://testing.example.org/resource.json" -H 'If-None-Match: "11263794d27103747aa3048b8d1ca76d" ' -i
HTTP/1.1 200 OK
Server: nginx/0.7.67
Date: Tue, 01 May 2012 12:33:36 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 200 OK
X-UA-Compatible: IE=Edge,chrome=1
ETag: "11263794d27103747aa3048b8d1ca76d"
Cache-Control: max-age=0, private, must-revalidate
Set-Cookie: _session_id=82d7a4d488e4bd295902cca2b0e3f0b6; path=/; expires=Wed, 01-May-2013 12:33:36 GMT; HttpOnly
X-Request-Id: b4121c1ba148f4a1212bee429b418a40
X-Runtime: 0.954076
X-Rack-Cache: invalidate, pass

[... Content here ... ]
@mikhailov
Copy link

Rack-cache follows RFC 2616 which describes E-Tag and Last-Modifed headers to be used with GET exclusively, so it called ConditionalGet, http://tools.ietf.org/html/rfc2616#section-9.3

@xentek
Copy link

xentek commented May 13, 2013

👍

@jkiddo
Copy link

jkiddo commented Jun 13, 2017

If-None-Match can also be used in both PUT's and POST's. There is nothing in the spec that says it can't: https://tools.ietf.org/html/rfc2616#section-14.26

@grosser
Copy link
Collaborator

grosser commented Jun 13, 2017

I also only know it as conditional get ... and always saw it implemented with a GET check ... is there any other library that supports this ?
Caching puts/posts seems like a terrible idea ...

@grosser
Copy link
Collaborator

grosser commented Jun 13, 2017

hmm I guess it can make sense if updating to the same state as before ... would love to see any other library that supports that though so rack-cache is not a 1-off with strange logic ...

@jkiddo
Copy link

jkiddo commented Jun 14, 2017

Conditional PUT's and conditional POST's can be used to create idempotent operations, meaning that ie. the same stuff is not created twice or updates are not processed in wrong order. See for instance https://www.hl7.org/fhir/http.html#cond-update

@grosser
Copy link
Collaborator

grosser commented Jun 14, 2017

Yeah, sounds good!
Want to make a PR ? ... I imagine it's just removing the right conditional somewhere ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants