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.

3
  • 1
    Someone needs to write a greasemonkey script that hides every question with the word "programmatically". IT'S A PROGRAMMING WEBSITE, NOT A PSYCHIC ONE. Jeeeeez. Commented Apr 1, 2010 at 7:27
  • read the question again: how to disable the cache programmatically using GWT, instead of using plain HTML... unless you consider HTML a programming language ? Commented Apr 1, 2010 at 7:40
  • 3
    this looks like a perfectly good question to me. Commented Apr 1, 2010 at 7:51

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.