Added immutable caching to the fingerprinted media types for the ConfigReader+Properties extension in the Website service target.

This commit is contained in:
2026-08-25 16:59:07 +02:00
parent 988090a511
commit 7aee1cd949
3 changed files with 56 additions and 6 deletions
@@ -61,6 +61,44 @@ struct ConfigReaderPropertiesTests {
#expect(reader(values: [.Analytics.websiteID: ""]).analytics == nil)
}
@Test(arguments: [
"shared.css",
"shared.js",
"milker-400.woff2",
"booth.mp4",
"portrait.jpg",
"portrait.webp"
])
func `cache control to mark the fingerprinted media immutable`(
file: String
) throws {
let header = try #require(reader().cacheControl.getCacheControlHeader(for: file))
#expect(header.contains("immutable"))
}
@Test(arguments: [
// The icons are exempt: a browser fetches `/favicon.ico` unversioned whatever the markup says, and the manifest names the PNGs.
"favicon.ico",
"icon-192.png",
"icon.svg"
])
func `cache control to leave the unversioned images mutable`(
file: String
) throws {
let header = try #require(reader().cacheControl.getCacheControlHeader(for: file))
#expect(!header.contains("immutable"))
}
@Test
func `cache control to have the unversioned text revalidate`() throws {
let header = try #require(reader().cacheControl.getCacheControlHeader(for: "robots.txt"))
#expect(header.contains("must-revalidate"))
#expect(!header.contains("immutable"))
}
}
// MARK: - Helpers