I just saw some examples about implementing the if-modified-since header. I really don't understand how it works very well. I have seen this example and it seems that if I set a date value to the header "Last-Modified", then I will get a value for the header "If-Modified-Since" if I check it later, am I right?
Also, It seems that, even though he provides a helper, I have to use it in every action?
I also looked into this post. He created a filter to handle the "If-Modified-Since" header. However, I don't understand much what he is trying to do in there, but as I can see, if the "Last-Modified" and "If-Modified-Since" headers are null then it will read it as dateModified = true and then it won't do anything inside the filter. Therefore, I think it depends on setting those header values in every action?
FInally,I'm not so sure about how should I use it, I think that I should send a new "Last-Modified" date value whenever I make an update to the view, is this the right aproach?
I came into your question and you actually helped me resolving the same problem you were having.
I'm going to explain you what happens with the header and what I've done to resolve it in C#:
You specify the Last-Modified as a server response.
In C# this is done by overriding the OnActionExecuting function on the controller you want. As an example, this is how I've done it:
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.RequestContext.HttpContext.Response.AppendHeader("Last-Modified", "Wed, 01 Sep 2004 13:24:52 GMT");
base.OnActionExecuting(filterContext);
}
Like you see I've specified this into the controller, so it will have effect for every action into the controller
Now, the first time you visit the page, you will get a response header like Last-Modified:Wed, 01 Sep 2004 13:24:52 GMT
. Next time you visit the page, you should see in your request header this If-Modified-Since:Wed, 01 Sep 2004 13:24:52 GMT
Hope this helps