Open egloffmark opened 4 years ago
Not working for me either. Not sure if this is designed to be a drop-in solution? I'm no expert on how caching works.
This not working for me either. Any additional documentation on how to make this work @arash16
How to know whether the cache is effective
Has anyone manage to get it working? Is this library no longer working at all and abandonned?
I also found https://github.com/legeneek/nuxt-page-cache which seems a bit promising if this package no longer works, but it's missing a big part of the implementation that the user must provide themselves.. the part that sets/gets the items from the cache
Unfortunately I don't have time to check for possible problems with customized configurations and other modules mixed in. We're already using this module in production, with 500k daily users, with no problems.
@arash16 thanks.. it's good to hear that it's working for you, are you using the latest version of nuxt?
Also.. am I right to notice that there is no file store? only memory? it would have been very nice to be able to use a file store so that the max could be a lot higher and it would work out well on sites with tons of pages and limited ram on the server instance.. any plans to add a file store?
Also.. am I right to notice that there is no file store? only memory? it would have been very nice to be able to use a file store so that the max could be a lot higher and it would work out well on sites with tons of pages and limited ram on the server instance.. any plans to add a file store?
An option for you might be to use NGINX as proxy/cache in front of nuxt. It is very mature, stable, configurable and well-documented. I use it in a file-based configuration with a very short duration to keep my small servers from getting hammered in the event of a large spike in traffic. It also handles TLS. It can keep serving a cached version if your nuxt server goes down. It is also trivial to instrument the cache with a response header so you can see that it is working.
In case you can't tell, I'm a big fan of nginx :stuck_out_tongue_closed_eyes:
The nginx docs, while very complete, can be a bit daunting as there are so many options. If you are interested, check out their guide to caching, I find it very approachable.
Thank you for your helpful reply @jeremy21212121, I'm also a fan of Nginx but am not so advanced that I would have thought this problem could be dealt with at that level. I will have a look at that guide. If you were so inclined however I would have found it very useful to see your server block for a site that uses this file-cache method : ) Looking at other people's solution is my preferred way of learning! Kind regards : )
Then that was i was scared about. Not working and not really maintain... Then I will search for something else :(
Hello there!
Indeed, for me it was not working either, but I think I found the reasons:
1.- If you don't use a custom function for the cache key, remove the key
function from the nuxt config.
2.- For some reason, req.host
and req.hostname
can be empty, so the default cache key function won't work. You can fix it this way.
3.- In Redis and cloud environments, most of the vendors do not allow you to use the Redis' CONFIG
(note that I also changed it to caps from the original code). So in your nuxt configuration, remove the configure
property.
To have all these fixes, and because it looks this is not mantained anymore, I forked the repo, built it and installed my own version from my GitHub repo's compile
branch.
Any documentation how to use it or even an example could be helpful. Especially some utils to check if it even work. Have any one managed to use this plugin and have some example?
I had solved via this:
key(route, context) {
// custom function to return cache key, when used previous
// properties (useHostPrefix, pages) are ignored. return
// falsy value to bypass the cache
if (route === '/') {
return 'page:home:string';
}
let page = route.substr(1).split('/');
page = page.join('.');
return `page:${page}:string`;
},
I had solved via this:
key(route, context) { // custom function to return cache key, when used previous // properties (useHostPrefix, pages) are ignored. return // falsy value to bypass the cache if (route === '/') { return 'page:home:string'; } let page = route.substr(1).split('/'); page = page.join('.'); return `page:${page}:string`; },
its Working !
If anyone is looking for a working solution, try this package instead: https://github.com/ziaadini/nuxt-perfect-cache
A fix of this problem https://github.com/Jeremy-DX/nuxt-page-cache
If anyone is looking for a working solution, try this package instead: https://github.com/ziaadini/nuxt-perfect-cache
Be Aware that with this package, the Redis URL and credentials are sent in clear text to all clients
I tried to use it but it is not working, the component which wraps a axios call still calls the webservice. I also tried to cache all pages by using just '/'. any idea what could be the issue? Thank you
nuxt config:
package.json: