Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Cache Tags blows up the response header #561

Open
didkan opened this issue May 3, 2021 · 0 comments
Open

Cache Tags blows up the response header #561

didkan opened this issue May 3, 2021 · 0 comments

Comments

@didkan
Copy link
Contributor

didkan commented May 3, 2021

When having API cache enabled (config.server.useOutputCache: true) and querying the API for many products it will add one cache tag per product in the response header. This will make the response header size to blow up and give all sorts or errors downstream. (e.g. Node errors and Nginx reverse proxy errors in my case).

In VSF there is a setting called config.server.useOutputCacheTagging which controls if the cache tags should be added to the response header. In VSF-API there is no such setting in effect. (Actually, the setting is there in default.json, but never used in the code).

Is there a reason you decided to not implement this setting? Will not sending the cache tags mess with some vital feature in VSF?

Cache tags are added here for products and categories:

if (config.server.useOutputCache && cache) {
const tagPrefix = entityType[0].toUpperCase() // first letter of entity name: P, T, A ...
tagsArray.push(entityType)
_resBody.hits.hits.map(item => {
if (item._source.id) { // has common identifier
tagsArray.push(`${tagPrefix}${item._source.id}`)
}
})
const cacheTags = tagsArray.join(' ')
res.setHeader('X-VS-Cache-Tags', cacheTags)
}

My suggestion is adding the useOutputCacheTagging setting to the if-statement like so:

if (config.server.useOutputCacheTagging && config.server.useOutputCache && cache)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant