RWS / dxa-web-application-dotnet

SDL Digital Experience Accelerator .NET MVC web application
Apache License 2.0
19 stars 35 forks source link

Outputcache empty content after redirect #94

Open sosatila opened 2 years ago

sosatila commented 2 years ago

If you do a redirect from your Page controller (use case described at the end), the DxaOutputCache action filters still continue executing. By the time the OnResultExecuting and OnResultExceuted are reached, the result is an empty string and the Page is cached in such a way. The Page's output caching would have been disabled by a dynamic child Entity, however it's never rendered (thus it does not disable the top level output cache) because of the Redirect on the Page level. The Page model is shared across static pages as well, so decorating it with DxaNoOutputCache is not viable.

Use case: if you control the Page's readability by its Metadata (you need to be within the Action to have the Page model to view the Metadata) and compare it

sosatila commented 2 years ago

The only mechanisms to influence the caching from outside of the filters are no good:

sosatila commented 2 years ago

Fixed and created a pull request https://github.com/RWS/dxa-web-application-dotnet/pull/95