William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

ajax: Automatically refresh webpage

ajax: Automatically refresh webpage

Every web developer/designer meets such issue: the webpage sometimes doesn’t refresh when clicking browser’s refresh button.

Here is the issue of browser cache. The browser cache management sometimes is out of our expectation, very weird, especially:

  • with multi-css and js files, as well as ajax.
  • with anchor

if you are in the period of debuging and testing, definately you expect it refresh everytime your modification. Here I list a simple solution like this:

$(document).ready(function() {
 var debug = true;
 $.rt = function() {
  return new Date().getTime();

When in debug mode (debug=true), everytime when you click, the browser cache will be refreshed by force, because the rt param changes: the current time in millisecond is always different.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: