-
Notifications
You must be signed in to change notification settings - Fork 331
Cache Tags blows up the response header #561
Description
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:
vue-storefront-api/src/api/catalog.ts
Lines 151 to 161 in ea24c74
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)