Coder Social home page Coder Social logo

Cache-Control problems about apicache HOT 6 CLOSED

tsubik avatar tsubik commented on May 17, 2024 1
Cache-Control problems

from apicache.

Comments (6)

tsubik avatar tsubik commented on May 17, 2024

All right, I can add another middleware after cache middleware to set Cache-Control to other value, but still I think that is a mistake to set Cache-Control to max-age.

from apicache.

dotob avatar dotob commented on May 17, 2024

Hi i want to second tsubik's request to not set this header. or make it optional. or is there a reasonable ides behind it that I do not understand?

From this apart I really like apicache! keep on the good work.

from apicache.

Balgorn avatar Balgorn commented on May 17, 2024

@tsubik So basically was dealing with the same problem. What I did right now to get around this issue is to set the duration in the middleware to a very high value (like 1 month). Afterwards I just add a middleware like this:

router.use((req, res, next) => {
	//needed for clients not to get cached content for ages and never retry
	res.header('cache-control', 'no-cache');
	next();
});

from apicache.

kwhitley avatar kwhitley commented on May 17, 2024

@tsubik @dotob @Balgorn This will be resolved in #97. I left the default behavior in to prevent breakage in existing deployed apps, but added the ability to override headers via global (or local middleware) options:

let cache = apicache.options({ headers: { 'cache-control': 'no-cache' } })

That work?

from apicache.

Balgorn avatar Balgorn commented on May 17, 2024

That should do it. If you can still set the maximum duration for your local Cache as before.

from apicache.

kwhitley avatar kwhitley commented on May 17, 2024

@tsubik @Balgorn @dotob - Ability to override headers via headers option (above) has been implemented in v0.9.0 and test coverage included to verify. Feel free to test it out!

from apicache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.