Have you cleared you cache? - Reduce unwanted caching - ASP.NET MVC VIEW HELPERSAdd to My Brief

Josh Doolan | 11/10/2011

One of the most common things we have to suggest to clients when we are failing to find common ground on the looks and functionality of  a developed site is: “Have you cleared your browser cache?”..familiar?

And sure enough 10 -15 secs later (or depending how long it’s been this the client has last done it) the cache is cleared and you are both now looking at the same CSS changes or be it javascript changes that where made.

Now to try and reduce this, here at wiliam we developed an MVC url helper that effectively appends the build number to the url request to make it unique, pretty simple concept that is relatively easy to implement and reuse.

The code for the helper class is as follows: 

It must be noted that consideration had to be made under what properties in assemblies are considered safe in medium trust environments. With the help of Phil Haack’s advise this was achieved: http://haacked.com/archive/2010/11/04/assembly-location-and-medium-trust.aspx

 After implementing the helper class in your desired view you just call the helper function on any of your resource references

 

 

 The result:

 

Pretty effective hey. Now I cannot take the wrap for this as this the work of my fellow talented colleagues here at Wiliam, Pete N, who was the mastermind behind the idea, then further refined by our Technical director Matt C.

 Enjoy.

tags: Web Development

Interested in learning more?

Wiliam is a leading supplier of web solutions and can provide expert advice to assist your business or organisation online.

Make enquiry   Request quotation

Comments

Share this page

Print this page Email this page to a friend Bookmark and Share

No Brief added yet.

My Brief results-driven approach emphasises a commitment to our clients needs through strategic analysis and best-practice.

Add to My Brief

Click on this icon to save item into My Brief. Retrieve, email and print

Drag & Drop

Drag & drop any iten with this icon into My Brief. Retrieve, email and print

Search Blogs