Description
When using the cache parameter (which is now default, since 2.7.0), using preview in the CMS causes the API to always return the preview version.
I believe this is because element-api always caches the request and does not check if the request is a preview request. In subsequent requests the cache is found and simply returned.
In 2.6.0 the preview was broken, but because the published version kept being served instead of the draft, now with the changes in 2.7.0 the cache is cleared when a draft is saved which causes the draft to be cached.
Steps to reproduce
- Enable cache in element-api (default)
- Supply the request with the correct X-Craft-Token
- Element-api fills cache with current draft
- Element-api serves cached draft version when requested without preview token
Additional info
- Craft version: 3.6.17
- PHP version: 7.4
- Database driver & version: MySQL 8.0.25
- Plugins & versions:
Description
When using the
cacheparameter (which is now default, since 2.7.0), using preview in the CMS causes the API to always return the preview version.I believe this is because element-api always caches the request and does not check if the request is a preview request. In subsequent requests the cache is found and simply returned.
In 2.6.0 the preview was broken, but because the published version kept being served instead of the draft, now with the changes in 2.7.0 the cache is cleared when a draft is saved which causes the draft to be cached.
Steps to reproduce
Additional info