title: Clever way to manage browser history
body: <p>I'm trying to implement a decent navigation in a AJAX application. What I am doing right now is the following:</p>
  
  <ul>
  <li>Every time a user clicks an AJAX link, the corresponding call is performed and the hash is changed.</li>
  <li>Whenever a new page is loaded, I check whether the hash is present and make the corresponding AJAX call to update the page. This ensures that bookmarks will work as expected.</li>
  <li>Every 500ms I check if the hash is changed and perform the corresponding AJAX call. This takes care of users pressing the back/forward buttons, albeit with a sligth delay.</li>
  </ul>
  
  <p>The third point is a bit annoying: I'd rather not have a timeout every 500ms just to check the hash, as most of the time it will stay the same.</p>
  
  <blockquote>
    <p>Is there a better way to manage this? I cannot think of any alternatives, but maybe I am missing something.</p>
  </blockquote>
  
  <p>Please, do not point me towards ready-made solutions, unless you know they are based on a different mechanism.</p>