OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

Issue with OutputCache for AjaxRequests #8629

Closed MatteoPiovanelli-Laser closed 2 years ago

MatteoPiovanelli-Laser commented 2 years ago

https://github.com/OrchardCMS/Orchard/blob/a402c82c23c726911dd0e704b3985e76de43c529/src/Orchard.Web/Core/Contents/Controllers/ItemController.cs#L49

ItemController.Display has na execution branch allowing to only return the Partial for the content being displayed when invoked by and ajax call (or similar).

However when computing the CacheKey, OutputCacheFilter doesn't differentiate between the two kinds of call. https://github.com/OrchardCMS/Orchard/blob/91a82535a24c8e13d1c16d078051e4b16ca98735/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs#L752

While it would be possible, as a workaround, to set the headers for that in the settings for the output cache, we would have to set those on every tenant anyway. We propose to have that directly in the "base" cachekey computed in the OutputCacheFilter, just like the test above is in the "base" ItemController.