About
RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 15 years old) and has a wealth of features making it an ideal choice to show charts on your website.

More »

 

Download
Get the latest version of RGraph (version 6.17) from the download page. There's also older versions available, minified files and links to cdnjs.com hosted libraries.

More »

 

License
RGraph can be used for free under the GPL or if that doesn't suit your situation there's an inexpensive (£99) commercial license available.

More »

Caching has been added to the RGraph forum

Written by Richard Heyes, RGraph author, on 12th August 2022

This may be interesting to you - I've just added caching to the RGraph forum. Two types have been added:

  1. HTTP caching headers
  2. Server-based pre-rendering

HTTP caching headers

Adding http headers for caching was an easy win - simply add the relevant http headers and browsers will attempt to cache the response (ie the page) that the server sends. The headers that have been added are as follows:

Cache-Control: public, private, max-age=604800
Expires: Fri, 19 Aug 2022 09:56:47 GMT

So the response is cached for a week and can be cached by your browser and also by other caches too (eg ones at your ISP or other intermediaries).

Server-based pre-rendering

This is a bit more interesting and a little bit more involved than simply adding some extra http headers to the response. What is done is a script that runs every so often makes a http request for the forum pages (the ones that are closed) - the resulting output is stored in a file on disk. The full html page that's written to disk is exactly what you see when you request the page with your browser.

Then, when you request a forum post (one that's closed), if it's in the cache it gets sent to your browser instead of the page being built from the contents of the database. So there's less load on the database (something I'm sure the ISP will thank me for). The cache is cleared and then the pages are re-cached every four hours by a cron job (a scheduled task).

If you're thinking of employing this type of caching then you need to ensure that the html that makes up the page doesn't change. If it does then you could end up with stale, cached copies of your pages being shown instead of up-to-date copies.