Make sure website cache is cleared in Internet Explorer when site is refreshed

I am using a website with Grails on a Tomcat server. When I refresh the website pages, Firefox is applying the updates correctly, but Internet Explorer seems to keep the cached values ​​until I explicitly delete the temporary internet files. How can I make sure Internet Explorer users have updated web pages when they refresh their site?

Edit: I've tested in Internet Explorer 9, but I'm guessing previous versions have the same problem.

Edit 2: The problem only happens when using css and javascript.

+3


source to share


2 answers


Ok the most reliable way to do this is to tell the browser to reload all css and javascript resources again, ignoring the cache, and for that you need to change the names of your css and javascript resources so that the browser knows it should reload them.

While you might have the tedious / impractical task of renaming all css and javascript resources every time you deploy a new assembly to production, you can use

u-performance plugin



for this purpose. This plugin, if configured correctly, ensures that when you create a new war, it will add the current version number from the repository to the filename and hence the filenames will be changed. The limitation with this would be that you will need to update all links to your css and javascript files in the gsp to include them using the tablib plugin and not directly (so when renaming the files, it also replaces the corresponding links in the gsp files) ...

In addition, this plugin can provide you with a number of other features that can help you increase the speed of your web application. For more detailed plugin functions click here

Hope it helps.

+1


source


A more up-to-date answer, like Bala's above, is to use the Resources plugin (included by default in Grails 2.0+ and available as a plugin for Grails 1.3+) in conjunction with the Cached Resources plugin .

The Cached Resources plugin is similar to UI performance in that it replaces all static content links with custom hash-based links. What's better than UI performance is that links are based on the content of the file, so they don't update unless the content of the static element changes. This is great because your user won't be forced to re-upload a file that hasn't actually changed.

The Resources plugin lets you define all your resources as modules - a very powerful way to describe the CSS, images, and JavaScript used in your application. The guide is very well written and will help you get started. It requires several steps:



  • Added <r:layoutResources/>

    to your layout in the tag <head>

    and just before the closing tag </body>

    .
  • Replacing all (or some) tags <link/>

    , <script/>

    and <img/>

    equivalents <r:require/>

    , <r:script/>

    and <r:img/>

    .
  • Better yet, move your CSS and JavaScript dependencies into a file ApplicationResources.groovy

    and set them up as reusable modules.

It's actually pretty quick to make a switch, and once you've done that, you can use other plugins like Zipped Resources (allows GZip compression) and YUI Minify Resources , which minifies CSS and JS files.

0


source







All Articles