One-click cache flushing

Mango loves to cache things. This propensity for saving everything and serving up old versions of things can be annoying, especially while previewing documents locally.

For a while now, it's been possible to clear Mango's "index" cache by visiting /flushcache/. So, over the past few weeks I've got pretty good at the following routine.

  1. Make a change to a Markdown document.
  2. Visit /flushcache/ in my browser.
  3. ⌘← to return to the rendered version of the document.
  4. ⌘R to refresh the page and have the change take effect.

While this only takes a second or two each time, similar inconveniences were what drove me from WordPress! The great thing about creating software is that one has the power to ease one's frustrations, which is what I did here.

"Flush cache" link
Click to flush the cache and have the updated content appear

If you add your IP address to INTERNAL_IPS in your project-level settings file, a handy link'll be inserted for you into each page via JavaScript. Clicking on this link will send an Ajax request to /flushcache/; upon receipt of a successful response the page will reload of its own accord. :)

This applies to both local testing and the live site. For local testing you'll need to add '127.0.0.1' to INTERNAL_IPS.

Because the relevant JavaScript snippet is only inserted into the page source for requests from one of the INTERNAL_IPS, only you will see this link.