https://kotlinlang.org logo
#ktor
Title
# ktor
c

Carter

10/12/2023, 3:03 PM
With Ruby on Rails, it is common to fingerprint your assets (images, CSS, javascript) with a hash. If the file contents change, the hash changes, which busts browser and CDN caches. Has anyone tried doing this with Gradle+Ktor server applications?
c

CLOVIS

10/12/2023, 4:12 PM
If you use the
CachingHeaders
plugin (documentation), Ktor adds the HTTP caching headers to all requests to static files, so there is no need to add hashes
c

Carter

10/12/2023, 4:14 PM
I don’t think that solves the same problem, does it?
c

CLOVIS

10/12/2023, 4:14 PM
Oops, it's the
ConditionalHeader
plugin that enables this functionality, sorry (documentation)
c

Carter

10/12/2023, 4:15 PM
I still don’t think that fully solves the issue.
It helps, certainly.
But if I’m sitting behind CloudFlare or another CDN, then doesn’t this still require visiting the origin for every request?
Even if the request doesn’t return content.
c

CLOVIS

10/12/2023, 4:18 PM
Indeed. You could greatly minimize it by using
CachingHeaders
as well.