vuestorefront / vue-storefront-api

Vue.js storefront for Magento2 (and not only) - data backend
https://www.vuestorefront.io
MIT License
348 stars 338 forks source link

Cache Tags blows up the response header #561

Open didkan opened 3 years ago

didkan commented 3 years ago

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: https://github.com/vuestorefront/vue-storefront-api/blob/ea24c74260c573907175c708a9a203fcfc2f7918/src/api/catalog.ts#L151-L161

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

if (config.server.useOutputCacheTagging && config.server.useOutputCache && cache)