如何以编程方式禁用与GWT的HTML缓存 [英] How to programmatically disable html caching with GWT

查看:93
本文介绍了如何以编程方式禁用与GWT的HTML缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我宁愿避免使用插入META HTTP-EQUIV =EXPIRES的方式来禁用浏览器中的HTML页面缓存? CONTENT = ...在我的html页面的头部,并且以编程方式代替它 - 如果可能的话。

令人惊讶的是,如果这对GWT / JavaScript是可能的(并且有任何影响),因为这意味着,页面将被缓存的问题和多久可以在用户查看页面时动态改变。



但即使这样,它也不会与代理一起工作,因为它们不会评估JavaScript ...对于您的Web服务器也是如此,它应该为该页面提供服务HTTP头。



因此,如果您想让缓存的http-equiv元标记变为动态,您应该可以在应用程序服务器上执行此操作:使用Servlet或任何动态页面(如果你愿意,甚至可以是PHP)来生成HTML页面。你甚至可以在那里设置真实的HTTP头(例如,通过使用 HttpServletResponse.setHeader(String name,String value)

Is there a way to disable the caching of html pages in the browser with GWT ?

I'd rather avoid using inserting META HTTP-EQUIV="EXPIRES" CONTENT=... in the header of my html pages, and do it programmatically instead - if possible.

解决方案

I'd be surprised, if this is possible (and has any effect) with GWT/JavaScript, because it would mean, that the question if and how long the page will be cached can change dynamically while the user views the page.

But even if it is, it won't work with proxies, because they don't evaluate JavaScript... The same is true for your web server, which should serve the page with that HTTP header.

So if you want to make your caching http-equiv meta tags dynamic, you should probably do that on the application server: Use a Servlet or any dynamic page (could even be PHP, if you want) to generate the HTML page. You could even set the real HTTP header there (e.g. in a Servlet by using HttpServletResponse.setHeader(String name, String value))

这篇关于如何以编程方式禁用与GWT的HTML缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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