How to stop chrome from caching REST response from WebApi?

后端 未结 1 786
名媛妹妹
名媛妹妹 2021-02-07 10:36

I am using ASP.NET WebApi and have the following code to stop caching in everything:

public override System.Threading.Tasks.Task Execu         


        
相关标签:
1条回答
  • 2021-02-07 11:16

    The answer is that Chrome does not like "Expires:Mon, 01 Jan 0001 00:00:00 GMT" (a fake date, basically).

    I changed my date to be what they use in their Google API, and it worked:

    Cache-Control:no-store, must-revalidate, no-cache, max-age=0
    Content-Length:1897
    Content-Type:application/json; charset=utf-8
    Date:Fri, 19 Jul 2013 20:51:49 GMT
    Expires:Mon, 01 Jan 1990 00:00:00 GMT
    Pragma:no-cache
    Server:Microsoft-IIS/8.0
    

    So, for anyone else who comes across this problem, make sure you set your Expires date to this arbitrary date!

    0 讨论(0)
提交回复
热议问题