I have a site that serves mostly static data from a database, so I'd like to have the maximum caching possible. The database is very weak and slow.
I am using shared hosting, so am limited to the [OutputCache] on the Controller and web.config
Is there a "max" strategy?
Ian
In this, you learn how to cache the output returned from a controller action so that a new user doesn't need to create the same content every time the action is called. Using the OutputCache attribute, you can enable output caching functionality by applying an individual controller action or an entire controller class.
By default, this attribute filter cache the data till 60 seconds.
Any (Default)- Content is cached in three locations- the Web Server, any proxy Servers and the Web Browser. Client- Content is cached on the Web Browser. Server- Content is cached on the Web Server. ServerAndClient- Content is cached on the Web Server and the Web Browser.
The output cache enables you to cache the content returned by a controller action. That way, the same content does not need to be generated each and every time the same controller action is invoked. Imagine, for example, that your ASP.NET MVC application displays a list of database records in a view named Index.
You can try going for the below option, it should give you 2147483647 seconds (24855 days) max duration for int32:
[OutputCache(Duration = int.MaxValue)]
Please note however that it is not guaranteed that your cache will be preserved exactly for the amount of time that you specify; it depends on memory utilization - if memory becomes too low, cache will be removing data automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With