Static Content Caching with ASP.Net MVC

I have been researching ways to cache contents in a website that I am working on. Below details how you could cache static contents in a ASP.Net MVC project.

This method does caching for CSS, JavaScript and image files as well.

Here is what you need to do 

Include the below content in your root web.config file, section system.webServer. The below code caches content for 7 days. 

  <staticContent>
      <clientCache  cacheControlMode="UseMaxAge" 
cacheControlMaxAge="7.00:00:00" />
    </staticContent>


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s