craftcms / element-api

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

Always remove cacheKey from config #152

Closed carlcs closed 3 years ago

carlcs commented 3 years ago

Description

Thanks for accepting #145. After your cleanup I’m now unable to (easily) set a cacheKey and disable caching for dev environments.

This is the config I was using before

'defaults' => static function() {
    $isDev = App::env('ENVIRONMENT') === 'dev';
    $request = Craft::$app->getRequest();

    return [
        'cache' => $isDev ? false : 'P1Y', // one year
        'cacheKey' => implode(':', [
            'elementapi',
            Craft::$app->getSites()->getCurrentSite()->id,
            $request->getPathInfo(),
            $request->getQueryStringWithoutPath(),
            $request->getHeaders()->get('X-API-Token'),
        ]),
    ];
},

Error message after updating to 2.8

Setting unknown property: craft\elementapi\resources\ElementResource::cacheKey

brandonkelly commented 3 years ago

Ahh that makes sense. Thanks.

brandonkelly commented 3 years ago

2.8.1 is out now with that change.