Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outputcache empty content after redirect #94

Open
sosatila opened this issue Aug 10, 2022 · 2 comments
Open

Outputcache empty content after redirect #94

sosatila opened this issue Aug 10, 2022 · 2 comments

Comments

@sosatila
Copy link

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
Copy link
Author

sosatila commented Aug 10, 2022

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

  • setting the Controller.ViewData[DxaViewDataItems.DisableOutputCache] in the controller's action is already too late, this check is only present in OnActionExecuting which is already finished by this point and the cache key is already pushed
  • setting the model's Volatile property to true is also no good, as this is checked for child actions only
    if (ctx.IsChildAction) {if (model != null && (IgnoreCaching(model) || model.IsVolatile)) { SetDisablePageOutputCache(ctx, true);

@sosatila
Copy link
Author

Fixed and created a pull request #95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant