Three Umbraco performace improvements
Output caching
Personally I like to implement mvvm architecture for my Umbraco solutions. This means each template has a surface controller to return the model to the view. This has the added advantage that I can implement MVC output caching. This is achieved by addeding the output caching attribute to controller actions. I use two parameters: Duration and VaryByParam. Use common sense when setting the cache duration. If your content changes frequently then set a low duration, however if your content rarely changes then set a higher duration. The VaryByParam I set to * to make sure that all variants of parameters are correctly cached.
[OutputCache(Duration=10, VaryByParam="*"]
public ActionResult Blog(){
return View();
}
Browser Cache
There are common frameworks that I use on projects, such as jQuery (javascript framework) and reset (common css file). There is no need to reload these files each time the website is loaded. These can be cached on the clients browser. Caching instructions are sent to browsers via http headers. The entries in the headers are populated by IIS. To instruct IIS on which content to cache, we simply add the below entry to web.config files placed in the folders containing the content we wish to be cached.
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
</staticContent>
</system.webServer>
The cacheControlMaxAge is in the format hh:mm:ss If you don't want a particular folder to be cached, simply add a new web.config to a subfolder with the following content.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
Content Compression
Using content compression, files are compressed on the server and decompressed on the client. Thus the transfer payload is reduced between the server and client. To enable content compression, simply add the following to the web.config file.
In addition set the following node attributes to true.
<location path="umbraco">
<system.webServer>
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
</system.webServer>
</location>
<location path="App_Plugins">
<system.webServer>
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
</system.webServer>
</location>