Check for Standards Before Creating a New One
I recently had a ticket opened on my team’s backlog board requesting the ability to bypass our API’s caching system. For context, our front-end team uses my team’s API to make fairly heavy requests to ElasticSearch, and one of the features of our API gateway is to cache the results of heavy aggregations for ~30 seconds. It turns out, every once in a while they need to run two of the same query within the ~30-second caching window and want an updated result set.
The request that was opened read something like, “the API needs a parameter to disable caching for certain queries”. When working in a REST-ish-ful API there are approximately math.MaxInt ways to accomplish that, and some of the first ones that immediately came to mind were:
- A
?cache=falsequery parameter - A
resource/no-cacheendpoint extension - A
cache: falseHTTP header - A
"cache": false"JSON payload in the body
As it turns out, there’s already a standard for this sort of thing, the Cache-Control request directives.
Cache-Control: max-age=<seconds>
Cache-Control: max-stale[=<seconds>]
Cache-Control: min-fresh=<seconds>
Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: no-transform
Cache-Control: only-if-cached
Using the standard header Cache-Control: no-store not only makes my job easier by requiring fewer API design decisions but also ensures that my API’s clients aren’t surprised by a new way to accomplish a common task.
I do want to point out, however, that just because you’ve decided to use a fairly well-supported standard, doesn’t mean there aren’t other standards your users will expect. It also doesn’t mean that your users are aware of the existence of the standard you’ve chosen.

Regardless of whether or not you think your API’s behavior is “standard” or “to be expected”, just add the behavior to your docs anyway. For me, the following snippet in our Readme.md was all we needed.
## Cache busting
If you don't want your query cached, use the Cache-Control header.
Cache-Control: no-store
Related Articles
Advanced Algorithms Course Released on Boot.dev
Apr 05, 2021 by lane
Sorry it took so long for me to get this one out! Data Structures and Algorithms 2 was just released, and I’m excited to let you all get your hands on it, even if you’re just auditing it for free! The more advanced material takes quite a bit longer to produce, I wanted to triple-check to make sure I got everything correct and that I’ve presented it in a way that makes it easy to understand.
Naming Variables the Right Way
Apr 01, 2021 by lane
I’ve noticed that bugs introduced into an existing code base are often due to poor variable naming more than one might suspect. For example, a developer uses a rateLimit variable expecting it to be denominated in seconds while it represents minutes, resulting in a 6x slower schedule. Another developer expects dbConnection to be an open database connection, but instead, it’s just the connection URI.
Top 8 Benefits of Functional Programming
Feb 25, 2021 by lane
Functional programming is a way to write code where programs are created strictly through functions. Functional programming has gained quite a bit of traction in recent years among the development community, mostly because of the benefits it provides.
What Is Dry Code, and Is It Always A Good Thing?
Jan 25, 2021 by lane
“Don’t repeat yourself”, or “DRY” for short, is a somewhat controversial principle of software development. It aims to make code cleaner, which is to say less buggy and easier to work with. DRY purports to accomplish this by reducing repetition in your codebase and replacing that duplicate code with abstractions like functions, classes, and methods.