Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Caching doesn't seem to be working #25

Open
mehdilouraoui opened this issue Nov 23, 2020 · 11 comments
Open

Caching doesn't seem to be working #25

mehdilouraoui opened this issue Nov 23, 2020 · 11 comments

Comments

@mehdilouraoui
Copy link

mehdilouraoui commented Nov 23, 2020

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 :)

@patrixr
Copy link
Owner

patrixr commented Nov 26, 2020

Hi @mehdilouraoui

That does seem off, although I don't have enough here to debug. Is the repo public by any chance ?

@Jbmanllr
Copy link

Same issue here, it's not caching anything, i also don't have the debug [Cache] Caching route /grids/* [maxAge=3600000] log .

@patrixr
Copy link
Owner

patrixr commented Jan 13, 2021

Hi @Jbmanllr

Could you please share the following:

  • your middleware config file
  • strapi version
  • cache middleware version

@Jbmanllr
Copy link

Jbmanllr commented Jan 13, 2021

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",

@Xerios
Copy link

Xerios commented Feb 12, 2021

I've encountered the same issue, after debugging for a while I found out the reason:

const shouldBust = key => _.find(rexps, r => r.test(key));

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.

@Jbmanllr
Copy link

Gonna go with another cache, this one is not maintained.

@derrickmehaffy
Copy link
Collaborator

I've encountered the same issue, after debugging for a while I found out the reason:

const shouldBust = key => _.find(rexps, r => r.test(key));

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.

@Xerios
Copy link

Xerios commented Feb 16, 2021

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 馃槃

@stafyniaksacha
Copy link
Collaborator

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 ?

@stafyniaksacha
Copy link
Collaborator

@mehdilouraoui @Xerios @Jbmanllr you can test the beta branch with strapi-middleware-cache@beta package tag !

@davidmgrana
Copy link

Any news about this? have same issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants