This is a general question about cache´ing (which i know very little about, so please be gentle if my questions is stupid, and feel free to come with suggestions of alternatives)
I don´t know if this is possible in a regular razor template and/or if it´s needed - or if it´s alternatively already taken care of, when the template is parsed.
But what I want ask is, if there is a way to cache some of the values created in razor template, since I don´t want them to tax the server everytime a page is requested. Below is an example of some string handling, that does not have to repeat itself every time this page is loaded.
@{
string readText = File.ReadAllText(htmlpage); // Read the entire contents of the htmlfile
var substringlength = readText.LastIndexOf("<div class=\"startInclude\"></div>") - readText.IndexOf("<div class=\"endInclude\"></div>");
string content = readText.Substring(readText.IndexOf("<div class=\"startInclude\"></div>"), @substringlength).ToString();
}
Is there a way that I can tell the program to cache the value of the string content and avoid going through the process leading to it´s value everytime? If so, any guidance on how i can do this?
/Hans