Copied to clipboard

Flag this post as spam?

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


  • Seaal 1 post 71 karma points
    Jul 18, 2016 @ 15:54
    Seaal
    0

    Published Content reverting to old version.

    I have a strange issue with Umbraco v7.4.3 in which the Published Content keeps reverting to a specific old version of the website. This content will revert back to this version everytime the app is restared, the app pool restarted and otherwise every few hours or so. The old version of the website it reverts to is always the same.

    Everything in the back office is up to date, and the only way to make the content reflect this is to use the "Republish Entire Site" option but that is not practical to do every few hours.

    My Umbraco setup is a little different to others. I expose the content through an api so SPAs on multiple different websites can consume the content. Here is the code that my ApiController is using:

    public IHttpActionResult Get(string website, string url)
        {
            IPublishedContent websiteNode = Umbraco.TypedContentAtRoot().FirstOrDefault(wn => wn.GetPropertyValue<string>("websiteId") == website);
    
            if (websiteNode == null)
            {
                return NotFound();
            }
    
            IPublishedContent pageNode = websiteNode.Descendants("page").FirstOrDefault(c => c.Name == url);
    
            if (pageNode == null)
            {
                return NotFound();
            }
    
            IHtmlString html = Umbraco.RenderTemplate(pageNode.Id);
    
            string umbracoUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority); 
    
            return Ok(new PageModel()
            {
                Title = pageNode.GetPropertyValue<string>("title"),
                MetaDescription = pageNode.GetPropertyValue<string>("seoDescription"),
                MetaIndex = pageNode.GetPropertyValue<bool>("seoIndex"),
                MetaFollow = pageNode.GetPropertyValue<bool>("seoFollow"),
                MetaKeywords = pageNode.GetPropertyValue<string>("seoKeywords"),
                Content = MakeImageUrlsAbsolute(html.ToHtmlString(), umbracoUrl)
            });
        }
    
    private string MakeImageUrlsAbsolute(string html, string umbracoUrl)
        {
            return html.Replace("src=\"/", "src=\"" + umbracoUrl + "/")
                       .Replace("url('", "url('" + umbracoUrl)
                       .Replace("href=\"/media/", "href=\"" + umbracoUrl + "/media/");
        }
    

    I have also checked the pages on the local Umbraco server. They are also showing the out of date version of the content.

    I assume this is a caching issue, but I don't know how to go about solving it, any help on the matter would be much appreciated.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies