0

I am thinking about implementing caching mechanics for asp.net mvc pages that gives you the latest version of a web page, but if the page didn't changed since the last time it was cached, it will return the cached result.

By the way, I wonder what are the limits of OutputCacheAttribute caching - many Locations can be used - Client Side, Server Side, Down Streaming, Any (default) and more. I wonder which is the fastest option, because I don't know what is the client side limitations - if it can store all the cached data I think it will definitely be the best caching location. So what data can be stored in each location?

A nice idea I came with is saving the last viewed page version of a certain address as hash inside a cookie, so when the user requests a page, I might give him the cached result if its hash didn't change. but If I calculate the current page hash, it might save traffic, but it still consume time for the server to process the request, so I still not sure what is the best way to implement it and how to yield the best results.

Both insights and ideas for implementing this as sophisticate as possible would be awesome.

Aviran Cohen
  • 5,581
  • 4
  • 48
  • 75
  • How do you define a page? There is really no such thing in ASP.NET MVC (if you are using actions/views/controllers). Does your proposed mechanism check the view, the controller logic, data being pulled from the db, javascript files, etc.? It sounds like a big undertaking and I'm interested to hear the scope you have in mind. – JP. Sep 30 '12 at 07:50

1 Answers1

0

Your idea sounds a lot like the http ETag header and 304 not modified response - http://en.wikipedia.org/wiki/HTTP_ETag#Typical_usage. Basically you don't need the custom cookie as the protocol already supports this.

As for returning the cached version with little impact on the server, use a Output Cache attribute as you already mentioned.

Betty
  • 9,109
  • 2
  • 34
  • 48