Comments (6)
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.
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.
@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.
@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.
That should do it. If you can still set the maximum duration for your local Cache as before.
from apicache.
@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)
- Browser ignoring cleared cache group HOT 3
- How to ignore cache but still save the result at the end HOT 2
- How do you manage a memory?
- Help with clearing cache HOT 1
- Dont serve cache if API authorization fails HOT 1
- apicache not supported on Node 14 HOT 7
- Having issues using ioredis and typescript
- How can I use stale-while-revalidate with max-age?
- Is there any limit to url length ?
- MAINTAINERS WANTED: Looking for active authors to help with the maintenance/evolution of apicache! HOT 6
- cache-control global options not working correctly HOT 2
- Event when cache is expired HOT 1
- Advice on preventing race conditions caused by multiple calls to the same endpoint made simultaneously (using Redis)? HOT 1
- Add Redis version 4 support HOT 5
- Load balancer + restify bug resolution
- Redis cached data for the same key is never returned, only continuously added on subsequent requests HOT 2
- is dynamic duration possible? HOT 3
- redisClient option not able to store apicache data in redis database HOT 4
- Set X-Cache in response header
- Possible memory leak in MemoryCache
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apicache.