title: How to prevent reload of pages in Chrome Extension?
body: <p>I have written a Chrome Extension to Clear TYPO3 CMS Caches right out of the browser's address bar.</p>
  
  <p>Now I would like to add an optional feature, to clear the caches automatically on page refresh . That means, when the user presses F5, CTRL+R, clicks the reload icon in toolbar or clicks in context menu to "Reload", first my ajax script should be executed (to clear the CMS cache) and after it, the page may get reloaded.</p>
  
  <p>Is there a possibility to do it with the Chrome API?</p>
  
  <p>I tried first the <code>window.onbeforeupdate</code> event in content script - and this is triggered always when the page is reloading, but also if I close the window or switch to another website. And furthermore I can't tell the browser to wait for my ajax request here.</p>
  
  <p>What works is to check in <code>document.onkeydown</code> event the keys 116 (F5) and 82 (R) with control key and use <code>event.preventDefault()</code>. But this will not cover the two other possible cases to refresh the cache.</p>
  
  <p>Thanks!</p>