Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS7.5 max-age issue(asp.net mvc output cache)

We use Windows server 2008 R2 Enterprise And IIS7.5.7600.16385, and i deployed a simple web (asp.net mvc, c#, .net framework 4.5.1) on the server. a controller like below, and *.cshtml only output a datetime:

public class DetailController : Controller
{
    [OutputCache(Duration = 300, VaryByParam = "id")]
    public ActionResult Index(int id)
    {
        return View();
    }
}

when i first request the url http://localhost:80/Detail/Index?id=3 , the response is correct:

Cache-Control:public, max-age=300
Date:Mon, 24 Oct 2016 12:11:59 GMT
Expires:Mon, 24 Oct 2016 12:16:51 GMT
Last-Modified:Mon, 24 Oct 2016 12:11:51 GMT

but, when i request the url again(ctrl+f5), the max-age incorrect (then the response is from the server cache):

Cache-Control:public, max-age=63612908450
Date:Mon, 24 Oct 2016 12:16:34 GMT
Expires:Mon, 24 Oct 2016 12:20:50 GMT
Last-Modified:Mon, 24 Oct 2016 12:15:50 GMT

i don't know why the max-age so large, and how it generated, it will reconvert when the output cache expired (ctrl+f5). In my production env, the incorrect max-age cause a url link click read the content from browser's disk cache.

any one know how and how to fixed it?

like image 391
mofee Avatar asked Oct 24 '16 12:10

mofee


1 Answers

This is a known issue and a bug is open for .NET 4.6.2 coming with KB151864.

Please see here for additional details: https://github.com/Microsoft/dotnet/issues/330

This is going to be fixed in .NET 4.6.3. I currently don't know if a fix will be made available earlier for 4.6.2.

The only known workaround at present is to downgrade and remove KB151864, when possible.

NOTE: the bug is affecting ONLY the compilation of the "max-age" attribute in the Cache-Control header for the cached responses. The actual caching mechanism and lifetime expiration is working.

like image 182
albigi Avatar answered Oct 20 '22 23:10

albigi