Sunday, October 12, 2025
HomeCSSLearn how to Clear Cache and Cookies on a Buyer’s Machine –...

Learn how to Clear Cache and Cookies on a Buyer’s Machine – Harry Roberts – Internet Efficiency Guide


Written by on CSS Wizardry.

Desk of Contents
  1. Getting Somebody to Clear Their Personal Cache
  2. Clear-Web site-Information
    1. Stopping Malicious Clears
  3. Clear-Web site-Information for Builders
  4. Clearing Cache on iOS

If you happen to work in buyer assist for any sort of tech agency, you’re most likely all
too used to speaking individuals by way of the intricate, tedious steps of clearing
their cache and clearing their cookies. Nicely, there’s a better means!

Getting Somebody to Clear Their Personal Cache

Making an attempt to speak a non-technical buyer by way of the steps of clearing their very own
cache is just not a simple activity—in no way! From figuring out their working system,
platform, and browser, to making an attempt to information them—invisibly!—by way of totally different
screens, menus, and dropdowns is an enormous ask.

Fortunately, any firm that has people in buyer assist could make use of a brand new
internet platform characteristic to make your complete course of a breeze: Clear-Web site-Information.

Clear-Web site-Information

A comparatively new HTTP
header
,
accessible in most fashionable browsers, permits builders to declaratively clear knowledge
related to a given origin by way of one easy response header:
Clear-Web site-Information.

Clear-Web site-Information: "cache", "cookies"

Any response carrying this header will clear the caches related to that
origin, so all of your buyer assist workforce wants now is a straightforward URL that they
can ship clients to that may clear all of their caches for them.

Stopping Malicious Clears

Screenshot of a fictional webpage showing three buttons, labelled ‘Clear cache’, ‘Clear cookies’, and ‘Clear all’.

Whereas it most likely wouldn’t be disastrous, it’s attainable {that a} unhealthy actor might
hyperlink somebody on to https://www.instance.com/clear and power an
unsuspecting sufferer into clearing their cache or cookies.

As an alternative, I might advocate that your /clear web page incorporates hyperlinks to URLs like
/clear/cache, /clear/cookies, /clear/all, every of which test and guarantee
that the referer request header is the same as https://www.instance.com/clear.
This manner, the one means the clearing works is that if the person initiated it
themselves. One thing possibly a bit like this:

const referer = req.get('Referer');

if (referer === 'https://www.instance.com/clear') {
  res.set('Clear-Web site-Information', 'cache');
} else {
  res.standing(403).ship('Forbidden: Invalid Referer');
}

Clear-Web site-Information for Builders

This isn’t the primary time I’ve written about
Clear-Web site-Information—I discussed it briefly in my 2019 article all about
setting
the right caching headers
. Nevertheless, that is the primary time I’ve targeted on
Clear-Web site-Information in its personal proper.

Naturally, the use case isn’t simply restricted to buyer assist. As builders,
we might have messed one thing up and have to clear all guests’ caches proper
away. We might connect the Clear-Web site-Information header to all HTML responses for
a brief time period till we expect the problem has handed.

Word that this may forestall something from going into cache whereas energetic, so that you
will discover efficiency degradations. Whereas ever the header is reside, you can be
always evicting customers’ caches, successfully disabling caching in your web site
the entire time. Tread fastidiously!

Clearing Cache on iOS

Sadly, Clear-Web site-Information is just not supported by Safari, and as all browsers
on iOS are simply Safari below the hood, there isn’t any fast option to obtain this for
any of your iPhone customers. Due to this fact, my recommendation to you is to instantly ask your
buyer Are you utilizing an iPhone?. If the reply is not any, direct them to
your /clear web page; if sure, then, nicely, I’m sorry. It’s again to the previous
original means.

It’s additionally price noting that Firefox doesn’t assist the particular "cache"
directive, it was eliminated in
94
, however I can’t think about
the common Firefox person would wish help clearing their cache.



Did this assist? We are able to do far more!


Hello there, I’m Harry Roberts. I’m an award-winning
Guide Internet Efficiency Engineer
, designer, developer,
author, and speaker from the UK. I write, Tweet, communicate, and share code about measuring and
bettering site-speed. You ought to rent me.

Now you can discover me on Mastodon.


Struggling? Repair It Quick!

Initiatives

Subsequent Look



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments