Giter VIP home page Giter VIP logo

Comments (9)

pi0 avatar pi0 commented on May 26, 2024 2

Cache should be happening as a serverMiddleware (or in API / Reverse proxy / Nuxt Proxy). I've checked both axios-extensions and cachios. Both are just using a simple and blind LRU cache which is something useful for server-side only. Still, if you think it is a good approach we can add any interceptor and custom adapter by extending axios.

Summary:

  • For browser caching: service workers provide a high quality caching mechanism
  • For server side: We can add such feature to proxy module . PRs welcome :)

from axios-module.

homerjam avatar homerjam commented on May 26, 2024

This is what I'm using for now, can anyone suggest if/how this could be integrated?

from axios-module.

mheppner avatar mheppner commented on May 26, 2024

Just as an FYI, this is being planned for the 1.x release of axios itself. Maybe there should be some collaboration to get this off the ground. See axios/axios#206, specifically tracked in issue 31.

from axios-module.

homerjam avatar homerjam commented on May 26, 2024

Interesting, though it looks like the discussion resolved to leaving it up to the user to implement via interceptors. Is there an argument that as this module already decorates axios with best practices for nuxt, caching could be one of them?

from axios-module.

mheppner avatar mheppner commented on May 26, 2024

I don't think I'm qualified to answer whether or not it should be implemented here, but I just wanted to make everyone aware that the feature is being planned for the upstream module. With that being said though, the author's proposed caching package has been dead for over a year, and the issue tracking the feature, originally opened in 2014, has been closed and not much activity has been added since then. It'd definitely be nice if this nuxt module could implement it, then port some of it back over to axios.

from axios-module.

pi0 avatar pi0 commented on May 26, 2024

@mheppner I'm totally up with this enhancement if we can add it as an opt-in option for axios module. But something important to mention, is we need to prevent sharing cache between SSR requests or maybe just use it for client side only. Caching stateful requests would introduce new security risks as well.

Also with workbox or pwa module, an standard service worker just does the same, transparently caching All XHR requests (including ones using axios) with less security risks :)

from axios-module.

mheppner avatar mheppner commented on May 26, 2024

@pi0 I honestly didn't know that about service workers, sorry! That would just be frontend caching, though, right?

from axios-module.

homerjam avatar homerjam commented on May 26, 2024

Service workers are frontend only, I've used them in the past but found they can introduce complexity. How do you invalidate a client's cache for example?

Not sure I understand enough to know the security risks, or indeed what exactly constitutes a stateful request. Also what would be the issue with sharing the cache between ssr requests? Genuine question as I think that's exactly what I'm doing!

Opt-in cache ftw.

from axios-module.

homerjam avatar homerjam commented on May 26, 2024

Hey @pi0, any idea if it might be possible to use the adapter option as this plugin does?

Should we choose a plugin to optionally include in the plugin template? Or is that too opinionated?

from axios-module.

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.