Tip: Invoice Ninja and Caching (ie with CDNs)

(CDN = Content Delivery Network)

Many of us use CDN’s to deliver content to the end user. They cache (almost) everything and massively reduce the pressure on our web servers. So “they are a good thing”.

However I recently helped a community member here who was having an issue with pages not updating after changes but which was fixed by deleting the cache at the CDN. I was doing some debugging on a test server of an issue in IN today when I got caught out again by the CDN cache so I went and did something about it.

I use Cloudflare which has excellent free and paid for plans. This is the only CDN I have experience of so if you are using another, you will need to go and hunt for this setting (if indeed it exists).

Cloudflare has a system called “Page Rules”. You can set up to 3 rules on the free plan.

Go to this page and click on “Create Rule” to set up a new rule. You need to enter the following:

  1. In the 1st box enter your URL, ie https://invoiceninja.com/* - note the “*” at the end. This tells Cloudflare to act on everything for this URL (you can get very granular with Page Rules if you want)

  2. In the Pick a Setting drop down select “Cache Level” and then in the drop down that appears next to it select “Bypass” and click on the Save and Deploy button

You’re done. Now Cloudflare won’t cache anything. The amount of data being passed back and forth between IN and clients is minimal so the performance hit will not be noticeable. On my main server, I’ve used this setting for 2 years. I’d completely forgotten to set it up for the test server which was dumb!

HTH

2 Likes