Skip to content

Always remove cacheKey from config#152

Merged
brandonkelly merged 1 commit intocraftcms:v2from
carlcs:patch-1
Sep 1, 2021
Merged

Always remove cacheKey from config#152
brandonkelly merged 1 commit intocraftcms:v2from
carlcs:patch-1

Conversation

@carlcs
Copy link
Copy Markdown
Contributor

@carlcs carlcs commented Sep 1, 2021

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

@carlcs carlcs requested a review from brandonkelly as a code owner September 1, 2021 13:09
@brandonkelly brandonkelly merged commit 343f567 into craftcms:v2 Sep 1, 2021
@brandonkelly
Copy link
Copy Markdown
Member

Ahh that makes sense. Thanks.

brandonkelly added a commit that referenced this pull request Sep 2, 2021
@brandonkelly
Copy link
Copy Markdown
Member

2.8.1 is out now with that change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants