Skip to content

Commit

Permalink
Report cache status to RUM
Browse files Browse the repository at this point in the history
We added the cache state to the Server-Timing header in alphagov/govuk-fastly#130

This uses the browser's performance API to check if there's a cacheHit /
cacheMiss value in the Server-Timing header, and if there is, report it
to RUM.

This will allow us to separate the performance of GOV.UK for cache hits
from cache misses, which will give us some useful insights into how much
the cache speeds things up, and how many requests are actually cached in
  • Loading branch information
richardTowers committed Jan 13, 2025
1 parent d51d4ab commit 792ab79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

## Unreleased

* Report cache status to RUM ([PR #4537](https://github.com/alphagov/govuk_publishing_components/pull/4537))
* Add type option to component wrapper helper ([PR #4536](https://github.com/alphagov/govuk_publishing_components/pull/4536))
* **BREAKING** Change devolved nations component type option ([PR #4535](https://github.com/alphagov/govuk_publishing_components/pull/4535))
* **BREAKING** Add component wrapper helper to intervention component ([PR #4378](https://github.com/alphagov/govuk_publishing_components/pull/4378))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@
// is used when a browser loads a page.
// [1]: https://github.com/alphagov/govuk-rfcs/pull/148
LUX.addData('http-protocol', navigationPerformance.nextHopProtocol)

const serverTiming = navigationPerformance.serverTiming
if (serverTiming) {
const cacheState = serverTiming.find(entry => ['cacheHit', 'cacheMiss'].includes(entry.name))
if (cacheState) { LUX.addData('cache', cacheState.name) }
}
}())

0 comments on commit 792ab79

Please sign in to comment.