Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

static content not caching in Asp.net MVC

I want to cache all my static content of mvc application.

I Added Web.config file like this in the Content folder enter image description here

I got proper response header from my server.

enter image description here

Even after receiving the header with max-age attribute, The next Request to the server goes with Cache-Control: no-cache

enter image description here

This again retrieve the whole data.

It is not caching.

I want to know What am i missing here. Thanks in advance.

like image 656
Victor Avatar asked Sep 18 '25 20:09

Victor


1 Answers

The no-cache in your screenshot is a request header not a response header.

It is likely being issued by your browser in response to you forcing a refresh (Control-F5). The browser is effectively saying 'please get me fresh data, I don't want the cached data'. The server-side can't control this - the client is the one making the request.

If you aren't forcing a refresh then you may have disabled your browser cache (e.g. https://stackoverflow.com/a/7000899/34092 ).

See also https://stackoverflow.com/a/14544664/34092 .

like image 138
mjwills Avatar answered Sep 21 '25 11:09

mjwills