Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 23, 2019 @ 11:09
    Ismail Mayat
    0

    This document is published but is not in the cache after build

    After doing a build all content is saying

    This document is published but is not in the cache

    We have to go to settings then settings / published status and reload memory cache.

    We think issue is with one of our models builder extended models:

            public DataDrivenProfile(IPublishedContent content) : base(content)
        {
            APIRequestConfig config;
            var urlSegments = HttpContext.Current?.Request?.Url?.Segments;
    
            if (urlSegments is null) return;
    
            if (urlSegments.Length > 1 && urlSegments[1].Contains("umbraco"))
            {
                config = GetBackofficeConfig();
            }
            else
            {
                config = GetFrontEndConfig();
            }
    
            HydratePersonData(config);
        }
    

    basically we are hydrating parts of the model with data from graphapi and that is locked by okta authentication the config for okta depending on whether you are viewing frontend or backend is slightly different. During hydration we have to use Request object to determine what kind of request is being made.

    I suspect during startup there is no Request and that is causing the nucache in memory to fail?

    Anyone any ideas?

    Regards

    Ismail

  • Stephen 767 posts 2273 karma points c-trib
    Oct 23, 2019 @ 11:12
    Stephen
    0

    That cannot work. ContentModels are direct representation of content items, and in v8 they are not created per request but cached for much longer. Which means that you simply cannot capture anything request-bound in a content model.

    What are you trying to achieve?

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 23, 2019 @ 11:15
    Ismail Mayat
    0

    Stephan,

    Hydration of the model from locked down graph api, we need rendering for front end and backend.

    However the authentication is different depending on whether you are viewing front end or backend so we need to be able to determine if request is front end or back end

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Oct 23, 2019 @ 11:25
    Kevin Jump
    101

    Hi

    can you move the code to a method and use in place of the property ?

    e.g

        public DataDrivenProfile(IPublishedContent content) : base(content) {} 
    
        public PersonData() {
             // all that code here ...
        }
    

    then the in the code in the razor file would be Model.PersonData() and that would be fetched on the request ?

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Oct 25, 2019 @ 09:15
    Ismail Mayat
    0

    This fixed the issue thanks kevin

  • Bishwajit 28 posts 98 karma points
    Jul 11, 2023 @ 09:13
    Bishwajit
    0

    Can some one help me to explain the fix of this issue "This document is published but is not in the cache" in Umbraco 8. As I am acing same. Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft