Speed up the API response time with SheetDB’s cache

This post will show you how to get faster responses to the API requests by using the caching feature in SheetDB app

Miko_Why Przestrzelski
SheetDB

--

We in SheetDB.io constantly work on new integrations and features of our app in order to make it useful for as many people and businesses as possible. What SheetDB does is turning a Google Spreadsheet into a JSON API which then can work with different services, tools and programming languages.

When fetching data from spreadsheets, especially large ones, the response time of your API might get elongated more than you would wish it to. If you’d like to decrease the time in which you get API to respond, there is a simple way to achieve that. SheetDB app lets you enable the caching feature that can significantly speed up getting data from your spreadsheets.

Moreover, it also brings an additional advantage to the table. Google Sheets API happens to have limits of request per project and per user, as listed below:

  • 500 requests per 100 seconds per project;
  • 100 requests per 100 seconds per user.

With SheetDB’s cache turned on you can bypass those limits and send more requests. By default, the application caches your API data for 15 seconds, although if you get yourself one of the paid plans, you can change this period in API settings even up to 7 days.

Caching guarantees the quickest response time, especially for large numbers of requests. I have tested the API response speed in Postman, to see how much faster it can go after being cached. Although I used quite a small file, even then the difference in the response time was significant.

The response without cache took 769 ms

As you can see above, the response time for the API took 769 ms. I disabled the cache with my endpoint itself which is described below. After turning on the cache, time for the response decreased by almost fourfold and took 199 ms.

The cached response took 199 ms

Notice that when caching is enabled, any changes to your spreadsheet will not be reflected in the API’s response, until of course the cache expires. So at most, when you set cache to 7 days and thereafter, say, one day later you decide to change the content at the Google Sheets website, for the next 6 days the GET endpoint will return the old data.

On the other hand, if any spreadsheet’s modifications made by SheetDB API occur, for example with the use of the POST request, the new request will clear the cache so that the next GET request returns new data immediately.

The same thing can be done manually at sheetdb.io with the Purge endpoint. It resets cache from the API settings at the website. You can also add to your endpoint a suffix, as shown below, which will also bypass the data stored in cache and replace them with the new content. You just have to construct your request as follows:

      GET https://sheetdb.io/api/v1/your_API_ID?ignore_cache=1

although it is not to be overused, due to taking a bit more time to respond.

I’m sure you’ll find the caching feature very useful and you’ll take advantage of its customizable settings. If you want to see more content on our API, see my other posts on SheetDB’s blog or visit SheetDB’s YouTube channel. If there’s any question you’d like to ask, or feedback worth sharing, leave a comment, find us on Twitter @SheetDB_io or email us at support@sheetdb.io.

--

--