Skip to content

[Laravel] Caching strategy and warm up #6735

Closed
@toitzi

Description

@toitzi

Description
While running into performance issues on my machine with requests taking up to seconds, i noticed that API Platform decides between 2 cache methods (array/file) based on the APP_DEBUG setting which was quite confusing. I get that the default value for using laravels cache setting CACHE_STORE is file and that in development instances you wouldn't wanna cache at all. So i can also see why you would check for another .env setting (like DEBUG). However i couldn't find that in the documentation (maybe i missed it). So i'd like to propose the following changes:

  1. Document that the DEBUG setting changes the caching strategy for api platform (or switch to a config setting or to ENVIRONMENT (production/local) setting or whatever - altough i would prefer something like using the ENVIRONMENT setting, ultimately i think it does not really matter as long as it is in the docs)

  2. Reagardless of the Above, keep array in "debug" cases but use the CACHE_STORE setting which comes with laravel for production e.g non debug. It defaults to file anyway and allows more control with no overhead.

  3. Since that cache is stored "forever" when it is first accessed (Metadata etc.. does not change on production environments), it could be cool/useful to hook into the Optimze command of laravel (described here) and "warm up" the cache with that data. I think that would be pretty neat.

Let me know what you think about that, i will happily submit a PR :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions