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

Should If-None-Match Headers Be Respected? #69

Closed
svozza opened this issue Feb 3, 2017 · 3 comments
Closed

Should If-None-Match Headers Be Respected? #69

svozza opened this issue Feb 3, 2017 · 3 comments

Comments

@svozza
Copy link
Contributor

svozza commented Feb 3, 2017

As it stands, the apicache middleware breaks Express's automatic handling of etags when the client supplies an If-None-Match header. I'm presuming it's something to do with overiding res.end but either way this is a useful feature that can reduce data sent to the client, which is especially useful in bandwidth constrained scenarios like mobile apps. It's a shame to have to chose between reducing traffic to the backend or payloads to the client. Here's a failing test case:

it('respects if-none-match header', function() {
        var app = mockAPI.create('10 seconds')

        return request(app)
          .get('/api/movies')
          .expect(200)
          .then(function(res) {
            return res.headers['etag']
          })
          .then(function(etag) {
            return request(app)
              .get('/api/movies')
              .set('if-none-match', etag)
              .expect(304)
              .expect('etag', etag)
          })
      })
@harikm-dmart
Copy link

I have as similar problem as well. When an If-None-Match header is supplied with the request, the cache is ignored although the intent is to use the cached content and check the ETAG.

@kwhitley
Copy link
Owner

kwhitley commented Jul 3, 2018

@svozza @harikm-dmart - This has been fixed, and @svozza I added your (perfect) test into the suite!

@svozza
Copy link
Contributor Author

svozza commented Jul 3, 2018

Brilliant. Thanks mate!

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

3 participants