tags:

views:

197

answers:

2

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.

+1  A: 

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

Chris Lercher
+1  A: 

i would say you can't. however, you can use tricks to always refresh your application by adding parameters on links, for example the URL to your app. a changed parameter is considered as a not-yet-fetched page

so try something like that:

<script type="text/javascript">
document.write("<"+"script src='client/client.nocache.js?today=" + getTime() + "'><"+"/script>");
</script>
dube