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

Get requests that return errors other than 500 are being cached #74

Open
emcpadden opened this issue Mar 11, 2015 · 2 comments
Open

Get requests that return errors other than 500 are being cached #74

emcpadden opened this issue Mar 11, 2015 · 2 comments

Comments

@emcpadden
Copy link

I had a get request that returned a status of 503 and that result was being cached.

When I debugged into the code i could see that in cache-encoder.js it was only looking for statusCodes !== 500 to determine whether the result was cacheable:

exports.cache = function(statusCode, headers, content, cb) {
  var buffer;
  if (statusCode && statusCode !== 500 && (headers || content)) {

I would think that it should only cache statuses between >= 200 and < 300.

@theganyo
Copy link
Contributor

Ah. Well, I think that's reasonably debatable... and I'm guessing we'd end up arguing forever about each status code and whether it is or isn't a correct to cache a given response under scenario X. :)

So... I guess I should probably add a setting or a callback so that users can choose the right thing to do in each case for their own circumstances.

@emcpadden
Copy link
Author

No problem Scott ... status codes are in the api of the beholder :)

I can see your point, for what I am doing, I would never want to cache anything but success (200 - 299). But, that said, I probably would want it even more restrictive than most an only cache 200.

When the problem happened for me I got a 503 (Service Unavailable) and unfortunately, it stayed in the cache even after the service came back.

In any case, I would definitely agree with you that a setting or callback would make a lot more sense.

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

2 participants