Skip to main content

70-562 Caching




Caching is to improve performance, caching pages and framents, and also data can dramatically improve the performance of a website.

The only cachin in classic asp were variables, and it's usefullness was very limited.

Now, in asp.net, there are mutliple type of caching.

1)Caching pages and user controls by the OutputCache directive, for how long and how many version are kept
2)Caching from code, more control than by page, but only used if it needs to change at run time.
3)Caching data, data storage is always in process, dataset, arrays, custom objects, similar to store in sessions state, but application wide, can determine how long the object in cache, and the cache can be flushed when the memory gets low.

Retriving a page from the cache is much faster than regenrating the page.

Static pages need to be cached as they dont change, for pages that do change, mutliple versions can be kept.

As a simple tutorial, output the page directive and it's duration in seconds, VaryByParam allows to specify which version based on a value of the param, Common.GetOutputCacheDirective(Server.MapPath(pageFileName));

You can encode those params as query string, or form values, it's possible to use * for all the parameters on teh page, or many params sepecated by a semicolon-demilmited list.

If asp.net finds the right combination of params in the cache, it uses it, otherwise, builds the page.

The params can also be the IDs of the controls on the form.

The HTTP header can also be used to identify page variations. VaryByHeader="Referer" in the page directive allows to vary by the caller(the calling page).

VAryByCustom can be used to vary by browser. In the global asax it's possible to override the GetVAryByCustomString value, which can be used for testing browser versions.

Comments

Popular posts from this blog

React JS Patterns

React JS is always evolving, and evolving quickly. These evolutions can be very significant ones, for example, the addition of hooks. React has a lot of code patterns, often these patterns are motivated by the DRY and/or the open-close principle. These patterns sometimes come in to replace a previous one, yet the previous ones still stays in use, as a consequence, the list of patterns keep growing. The goal of the next few posts will be to list the patterns commonly used in React JS developpement. Some patterns are more specific to JSX and I will start with these, and maybe add patterns specific to Redux.

70-562 ListView

List View is a versatile control that allows to work with a signle control rather than many smaller controls. Provides rich sorting, deleting, editing, it is one of the most flexible grid control. Design view can fill the ListView with fake data to give an overview. In designer, the configure list view link might not show, (currently a bug), to fix configure the datasource but cancel then click configure datasource again and this time click finish and the Cofnoigure ListView link will show up in the smarttag. You can choose templates, LayoutTemplate is crucial, ItemTemplate(a row is part of a table, in a list view they are called items since they don't have to correspond to a table row), AlternatingItemTemplate, ItemSeparatorTemplate, SelectedItem, EmptyItemTemplate, EditItemTemplate, InsertItemTemplate allows to customize what the user will be presented when creating an item, EmptyDataTemplate. The itemPlaceHolder and the groupPlaceHolder are important elements as the will b...

70-562 Coding Web Parts

Coding Web Parts. The Web Part framework helps you write code to control all aspects of web parts behavior. Not all things are automaticaly handled, changing the display mode, changing the personalizing scope, reseting data, creating web parts with custom or user controls, and creating connections. PersonlizationADministration.FindSharedState method allows to find the personlization data using the FindUserState and ResetUser state. Web parts can be implement following those typical patterns, Master/Details(one shows the order, the other the items), Filter by Form(one shows the order, other allows to edit items, List/Form InputDisplay: one to edit, the other to view A web part can be a data provider, or consumer, or both. When using provider/consumer, The data is not guaranteed to be final until the prerender event. Custom controls as web parts allow to add new verbs to web parts, like, Verify. Specifying whether a control is a provider or cusumer is done in the cla...