strapi-middleware-cache
strapi-middleware-cache copied to clipboard
Caching doesn't seem to be working
Hey!
Firstly, many thanks for this very useful package! 👍
I've added the following code in at config/middleware.js
module.exports = ({ env }) => ({
settings: {
cache: {
enabled: true,
models: ['grid'],
}
}
})
I can see the mounting and the using storage engine logs but I have no log from the caching routes.
I also tried with grids
, nothing happens.
Here are the logs:
$ strapi develop
[2020-11-23T20:27:40.633Z] debug [Cache] Mounting LRU cache middleware
[2020-11-23T20:27:40.634Z] debug [Cache] Storage engine: mem
Missing this log :
debug [Cache] Caching route /grids/* [maxAge=3600000]
Any idea?
Many thanks :)
Hi @mehdilouraoui
That does seem off, although I don't have enough here to debug. Is the repo public by any chance ?
Same issue here, it's not caching anything, i also don't have the debug [Cache] Caching route /grids/* [maxAge=3600000]
log .
Hi @Jbmanllr
Could you please share the following:
- your middleware config file
- strapi version
- cache middleware version
Sure! Thanks for your help:
- Middleware:
module.exports = { gzip: { enabled: true, options: { br: false } }, cache: { enabled: true, models: ['pros'], } };
Strapi version: 3.4.1
Middleware version: "strapi-middleware-cache": "^1.2.0",
I've encountered the same issue, after debugging for a while I found out the reason:
https://github.com/patrixr/strapi-middleware-cache/blob/b32979ab03d52699b47888e996aaf54918d6fcde/lib/index.js#L202
SHOULD BUST? [ '/learn_articles/test-article?' ]
[
/^\/learn_articles\/1/,
/^\/learn_articles\?/,
/^\/authors/,
/^\/learn_tags/
] => []
So the issue in my case is that the library assumes I'm using IDs, but I'm actually using slugs instead of IDs which kind of breaks the system.
Gonna go with another cache, this one is not maintained.
I've encountered the same issue, after debugging for a while I found out the reason:
https://github.com/patrixr/strapi-middleware-cache/blob/b32979ab03d52699b47888e996aaf54918d6fcde/lib/index.js#L202
SHOULD BUST? [ '/learn_articles/test-article?' ] [ /^\/learn_articles\/1/, /^\/learn_articles\?/, /^\/authors/, /^\/learn_tags/ ] => []
So the issue in my case is that the library assumes I'm using IDs, but I'm actually using slugs instead of IDs which kind of breaks the system.
To use Slugs this would be a custom route that the middleware layer isn't aware of, for something like this you would need to customize the middleware.
I'm aware, just pointing out to whoever might encounter any issues when using custom routes.
I was expecting this library to be less complicated. In my usecase I rarely update the content, so simply caching everything and busting everything when I do any sort of change would've been more than enough 😄
Hello @mehdilouraoui your issue should have been resolved as of 1.5.0 release !
For custom routes (with slugs), can you add a sample of what you need in comment on the #43 PR ?
@mehdilouraoui @Xerios @Jbmanllr you can test the beta branch with strapi-middleware-cache@beta
package tag !
Any news about this? have same issue