Added immutable caching to the fingerprinted media types for the ConfigReader+Properties extension in the Website service target.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user