Force Cache Refresh When Editing and Redisplaying

2020-03-25 22:54发布

I am using asp.net mvc and have a view that displays an item and a view that allows editing an item. When the user submits an edited item, it redirects them to the view for that item. The changes are not being reflected when they are redirected because the item view is being cached. The view item page can also be edited inline and then a submit button uses javascript to submit and then refresh the page.

I've noticed that stackoverflow somehow makes this work when you edit an item, it redirects you to the page with your changes reflected. Their caching is set to public, max-age=120 so I am surprised the browser doesn't pull a local copy without the reflected changes...

Anyway, is there a way to force a cache refresh in these cases? I would prefer not to append a random query string value, but if there is no other way that is what I will do.

1条回答
The star\"
2楼-- · 2020-03-25 23:22

There is a cache-control meta tag you can set. Put this in your head section

<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Jan 1980 1:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

http://www.chami.com/tips/internet/113096I.html

or the .Net way

<%@ OutputCache Location="None" VaryByParam="None" %>

http://www.dailycoding.com/Posts/how_not_to_cache_a_page_output_in_aspnet.aspx

查看更多
登录 后发表回答