强制高速缓存刷新当编辑和重新显示内容 [英] Force Cache Refresh When Editing and Redisplaying Content

查看:116
本文介绍了强制高速缓存刷新当编辑和重新显示内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用asp.net mvc的,并有显示项目视图和视图使编辑项。当用户提交一个编辑过的项目,它其重定向到该项目的看法。当他们被重定向,因为该项目视图被缓存的变化没有被反映出来。视图网页也可以在线编辑,然后一个提交按钮使用JavaScript来提交,然后刷新页面。

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.

我注意到,计算器不知何故使得这项工作,当你编辑项目,它会将您重定向到该页面与您的更改反映出来。他们的缓存设置为公开,最大年龄= 120,所以我很惊讶没有反映变化的浏览器不拉本地副本...

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...

不管怎样,有没有办法强制在这些情况下,缓存刷新?我想preFER不追加一个随机的查询字符串值,但如果没有其他的方式,是我会做什么。

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.

推荐答案

有是你可以设置一个缓存控制元标记。把这个在你的脑袋节

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

或.net方式

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

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

这篇关于强制高速缓存刷新当编辑和重新显示内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆