craftcms / element-api

Create a JSON API/Feed for your elements in Craft.
MIT License
498 stars 56 forks source link

disable route/response caching in devMode #174

Closed marcusgaius closed 1 year ago

marcusgaius commented 1 year ago

Added option to suppress endpoint caching in devMode

Description

Ability to forego the tedious activity of always having to purge caches while testing changes in the code.

Related issues

brianjhanson commented 1 year ago

Thanks for the PR!

At first glance, it looks like you could achieve the same goal using the defaults config settings.

use craft\config\GeneralConfig;

return [
    'defaults' => [
        'cache' => !GeneralConfig::instance()->devMode(),
    ],

    'endpoints' => [ // endpoints ]
];

Is there something about your use case that isn't covered by that method?

marcusgaius commented 1 year ago

@brianjhanson No, this covers it. I didn't realize from the docs this would be how to use it. Thank you very much.

brianjhanson commented 1 year ago

👍 excellent!