Comments (15)
Fastify can have a cache solution as a plugin? like these but internal one.π€
from fastify.
IMHO we have two layers of this.
- methods to detect and process those headers in
Request
- a plugin that uses those, and actually do caching
Would you like to start a plugin?
from fastify.
Reference for people wishing to tackle this issue: https://tools.ietf.org/html/rfc2616#section-14.9
from fastify.
But why should this be in fastify?
Cannot this be a plugin that installs some kind of middleware?
Is yes, why is this needed for the v1.0.0 release?
from fastify.
@allevo I mean we need to support what is written in https://hapijs.com/tutorials/caching?lang=en_US as "client side caching" within fastify itself, and maybe server-side caching with plugin.
from fastify.
Oooh, okay. That gives me ideas....
from fastify.
@mcollina fastify
can simply parsing the header if we want (but again, why not in a middleware?) or provide a simple shorthand to set the cache header (but again, why not in a decorator?)
from fastify.
ETag support out of the box is great since it can save clients significant bandwidth, e.g for mobile devices consuming an API. Similar for other cache headers @jsumners linked.
I think things like apicache
or my own express-expeditious
fall into a different category.
from fastify.
Of course, performance-wise it might be best as a plugin - just sharing thoughts on general use case.
from fastify.
Etag support out of the box destroys performance :/. After we have spent time generating a response, our cost has already been paid, and bandwidth is mostly cheap. 304s are better sent from a web server (nginx) or a CDN.
IMHO we should just provide some utilities to implement all of that if someone needs to. Itβs a bunch of methods/accessors on Request and Reply.
from fastify.
Here's my initial implementation. I intend to look at catbox
style support before an actual release. https://github.com/fastify/fastify-caching
from fastify.
good job! we need the accessor on Request as well!
from fastify.
@mcollina file bugs over on that repo so they can be a TODO list.
from fastify.
This can be closed, further discussion could be done in fastify/fastify-caching :)
from fastify.
Fixed by https://github.com/fastify/fastify-caching/releases/tag/v1.0.0
from fastify.
Related Issues (20)
- Where is the documentation for <Reply>.sendFile? HOT 2
- Switch to ajv/2020 for fastify 5 HOT 7
- Fastify v5 coordination HOT 7
- Does Validation-and-Serialization document's outdated?
- Should we drop Node.js v18 for v5? HOT 11
- `disableErrorLogging` option HOT 1
- Request hangs if you `await reply.status` in an async handler. HOT 15
- querystring with property of type number fails HOT 7
- onError hook is called before errorHandler when error is thrown in onRequest hook HOT 7
- Approval Request for Future State Proposal HOT 20
- Expose .writeEarlyHints()
- Logger methods are not bound to this HOT 4
- Whole API breaks when passing non-async function to fastify.register HOT 3
- Documentation and example of webhook signature check (through rawBody) HOT 1
- req.headers or req.query null in a 404 handler HOT 6
- Update reply.then and fastify.then types to use branded types to please typescript-eslint HOT 5
- hasRoute not working properly HOT 7
- Serverless Firebase Functions (v2) Issue: "... failed to start and listen on the port defined provided by the PORT=8080 ..." HOT 2
- import/require fastify module is incredibly slow > 300 ms HOT 3
- Custom format for ajv gets overwritten by ajv-formats HOT 4
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 fastify.