Coder Social home page Coder Social logo

http caching headers about fastify HOT 15 CLOSED

fastify avatar fastify commented on July 30, 2024 3
http caching headers

from fastify.

Comments (15)

cagataycali avatar cagataycali commented on July 30, 2024

Fastify can have a cache solution as a plugin? like these but internal one.πŸ€”

from fastify.

mcollina avatar mcollina commented on July 30, 2024

IMHO we have two layers of this.

  1. methods to detect and process those headers in Request
  2. a plugin that uses those, and actually do caching

Would you like to start a plugin?

from fastify.

jsumners avatar jsumners commented on July 30, 2024

Reference for people wishing to tackle this issue: https://tools.ietf.org/html/rfc2616#section-14.9

from fastify.

allevo avatar allevo commented on July 30, 2024

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.

mcollina avatar mcollina commented on July 30, 2024

@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.

jsumners avatar jsumners commented on July 30, 2024

Oooh, okay. That gives me ideas....

from fastify.

allevo avatar allevo commented on July 30, 2024

@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.

evanshortiss avatar evanshortiss commented on July 30, 2024

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.

evanshortiss avatar evanshortiss commented on July 30, 2024

Of course, performance-wise it might be best as a plugin - just sharing thoughts on general use case.

from fastify.

mcollina avatar mcollina commented on July 30, 2024

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.

jsumners avatar jsumners commented on July 30, 2024

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.

mcollina avatar mcollina commented on July 30, 2024

good job! we need the accessor on Request as well!

from fastify.

jsumners avatar jsumners commented on July 30, 2024

@mcollina file bugs over on that repo so they can be a TODO list.

from fastify.

delvedor avatar delvedor commented on July 30, 2024

This can be closed, further discussion could be done in fastify/fastify-caching :)

from fastify.

jsumners avatar jsumners commented on July 30, 2024

Fixed by https://github.com/fastify/fastify-caching/releases/tag/v1.0.0

from fastify.

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.