What is Post Cache substitution?
The Post cache substitution is used when we want to cache the complete page but also require some of the dynamic region inside that cached page. Some examples such as RandomPhotos, QuoteoftheDay, and AdRotator etc. Where we can implement the Post Cache Substitution.
Post-cache substitution can be achieved by 2 means:
1) Call the new Response.WriteSubstitution process, passing it a reference to the desired substitution method callback.
2) Add a control to the page from the desired location, and fixed its methodName attribute to the name of the callback method.
![816_post cache substitution.png](https://www.expertsmind.com/CMSImages/816_post cache substitution.png)
Figure: - "Writesubstitution" in action
We have "GetDateToString()" a static function . We pass the response substitution callback to the "WriteSubstitution" process. So now when ASP.NET page framework retrieves the cached page, it automatically triggers your callback process to get the dynamic content. Now it inserts your content into the cached HTML of the page. Even if your page hasn't been cached yet (for example, it's being rendered for the first time), ASP.NET still calls your callback into the same way to get the dynamic content. So you create a process which generates some dynamic content, and by doing so you assure that your process is always called, and it's content is never cached.
The example above was by using "WriteSubstitution" now lets try to see how we can do by using "" control. You can get the "" control from the editor toolbox.
![75_post cache substitution1.png](https://www.expertsmind.com/CMSImages/75_post cache substitution1.png)
Figure: - Substitution Control
![1735_post cache substitution2.png](https://www.expertsmind.com/CMSImages/1735_post%20cache%20substitution2.png)
Figure: - Substitution in Action