Coder Social home page Coder Social logo

hybrid-framework-best-practices's People

Contributors

chrisheijnen avatar jbreuer avatar jeavon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hybrid-framework-best-practices's Issues

Cache Can be Polluted by Preview Content

Was just reviewing the GetVaryByCustomString in the Global: https://github.com/jbreuer/Hybrid-Framework-Best-Practices/blob/master/development/Umbraco.Extensions/Utilities/Global.cs

Doesn't look like it's taking into account that the user may be previewing the site. Doesn't that mean elements that are being previewed (i.e., potentially not yet published) may get cached and viewed by normal site visitors who are not in preview mode?

I ask because I've come across this issue in the past. Below is one way to solve it (though, I think there is a built-in Umbraco function you can use rather than looking at the cookie):

public override string GetVaryByCustomString(HttpContext context, string custom)
{
    custom = custom ?? string.Empty;
    if (custom.ToLower() == "Something".ToLower())
    {

        // Domain is included so requests cached per domain aren't shared.
        var fullUrl = new Uri(context.Request.Url, context.Request.RawUrl).AbsoluteUri;
        var key = GetKeyWithBuster(fullUrl);


        // Avoid contaminating the primary cache with Umbraco previews.
        try
        {
            var cookie = context.Request.Cookies["UMB_PREVIEW"];
            if (cookie != null && !string.IsNullOrWhiteSpace(cookie.Value))
            {
                key = key + "_PREVIEW_" + cookie.Value;
            }
        }
        catch { }


        // ... a few other key modifications removed...


        // Return cache key.
        return "something=" + fullUrl + " * key=" + key;

    }
    return base.GetVaryByCustomString(context, custom);
}

Upgrade to Umbraco 7

I just attempted to upgrade this best practice solution to Umbraco 7 but couldn't get it to work (not sure where umbraco.editorControls should come from).

I notice that this hasn't been touched for a number of months - is there any chance you could update for Umbraco 7 or provide any info on how we should go about it?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.