Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Robin Hansen 135 posts 368 karma points
    Dec 09, 2023 @ 12:11
    Robin Hansen
    0

    Cannot get Response Caching to work

    I'm usin an Umbraco version 12.3.3 installation, and I'm trying to get Response Caching to work acording this tutorial: https://docs.umbraco.com/umbraco-cms/reference/response-caching

    No matter what I do I cannot get 'Cache-Control' to show anything else.

    I even tried to set my response header directly in my RenderController:

    HttpContext.Response.Headers.Add("Cache-Control", "public, max-age=900");
    

    with no luck either... - I geting to think it's some kind of setting I'm not aware of... - plz help :-|

    enter image description here

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Dec 09, 2023 @ 22:29
    Marc Goodson
    0

    Hi Robin

    With the example to create a default controller and add the [ResponseCache attribute to decorate it... There is an extra step not mentioned in the example, which is to tell umbraco to use your default controller for all requests...

    https://docs.umbraco.com/umbraco-cms/implementation/default-routing/controller-selection#change-the-default-controllers

    Anyway it may be something else at issue, but thought I'd mention in case that is the bit your missing..

    Regards

    Marc

  • Robin Hansen 135 posts 368 karma points
    Dec 10, 2023 @ 17:04
    Robin Hansen
    100

    From the log:

    The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.

    Turned out I had a contactfom on the page using BeginUmbracoForm.

    Since the form doesn't send anything to the database, but send maills only, I figure I can set the AntiForgeryToken to false. Then my page is cached :-)

    https://our.umbraco.com/forum/umbraco-forms/88247-antiforgerytoken-and-page-cache

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Dec 10, 2023 @ 20:45
    Marc Goodson
    0

    Aha!

    Glad you got to the bottom of it, yes, a form with antiforgery shouldn't be cached!

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft