adobe / aem-project-archetype

Maven template to create best-practice websites on AEM.
https://experienceleague.adobe.com/docs/experience-manager-core-components/using/developing/archetype/overview.html
Apache License 2.0
548 stars 426 forks source link

Remove User-Agent from vary header to improve cache-hit-ratio on CDN #680

Open keepthebyte opened 3 years ago

keepthebyte commented 3 years ago

Expected Behaviour

CDN or proxy is caching resources with high cache hit ratio.

Actual Behaviour

This is not the case as AEM per default adds the user agent to the vary header, that forces the CDN/proxies to add the user agent string to the cache-key, hence making caching ineffective. This is most likely a legacy setting, back from when CMS would render different output based on user agent string - e.g using WURFL for device detection and adjusting the output. AEM is no longer doing that and it's not recommended to do this anymore.

For example see:

See line 43 in: https://github.com/adobe/aem-project-archetype/blob/master/src/main/archetype/dispatcher.cloud/src/conf.d/available_vhosts/default.vhost

See line 20 in https://github.com/adobe/aem-project-archetype/blob/master/src/main/archetype/dispatcher.ams/src/conf.d/available_vhosts/aem_publish.vhost

More: https://github.com/adobe/aem-project-archetype/search?q=Header+append+Vary+User-Agent+env%3D%21dont-vary

This has already been fixed in the reference https://git.corp.adobe.com/Granite/dispatcher-k8s-base/pull/48/files and now also needs to be fix in the project archetype. wknd.site , aemcomponents.dev and Odin have been updated with the updated config.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Platform and Version

Sample Code that illustrates the problem

Logs taken while reproducing problem

keepthebyte commented 3 years ago

look like https://github.com/adobe/aem-project-archetype/blob/master/src/main/archetype/dispatcher.cloud/src/conf.d/available_vhosts/default.vhost was already fix in #669