jbreuer / hybrid-framework-best-practices Goto Github PK
View Code? Open in Web Editor NEWA framework for Umbraco with some examples
A framework for Umbraco with some examples
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);
}
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.