Comments (9)
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.
This is what I'm using for now, can anyone suggest if/how this could be integrated?
from axios-module.
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.
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.
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.
@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.
@pi0 I honestly didn't know that about service workers, sorry! That would just be frontend caching, though, right?
from axios-module.
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.
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)
- axios.$get is no function HOT 2
- nuxt/axios options doesn't seem to work HOT 2
- Problem with ssr Cors then axios and proxy
- filename.split error on nuxt generate and ssr HOT 2
- dont work on nuxt rc.6
- Cannot send cookies through server side
- Update to latest axios HOT 5
- Export `NuxtAxiosInstance` typings HOT 3
- Why does nuxtjs/axios trigger options requests
- diferrent url in nuxt 3
- Nuxt 3: Cannot start nuxt: Cannot read properties of undefined (reading 'options') HOT 3
- Nuxt3, how to fix this error HOT 2
- [Nuxt 2] defu__WEBPACK_IMPORTED_MODULE_3__ is not a function
- Is this repo still maintained & any plans to upgrade to axios v1.* ? HOT 2
- Status code is not returned for 413 responses HOT 1
- Last part of url getting removed during request
- Cannot restart nuxt: Cannot read properties of undefined (reading 'options') HOT 1
- nuxt/axios this.$axios.get() options doesn't seem to work
- Authorization header is not being set with Auth Module cookie strategy
- Release with latest axios HOT 1
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 axios-module.