@@ -87,11 +87,11 @@ const app = new Hono<{ Bindings: Bindings }>();
8787
8888app .all (' *' , async (c ) => {
8989 const url = new URL (c .req .url );
90-
90+
9191 // Only use the path for the cache key, removing query strings
9292 // and always store using HTTPS, for example, https://www.example.com/file-uri-here
9393 const someCustomKey = ` https://${url .hostname }${url .pathname } ` ;
94-
94+
9595 // Fetch the request with custom cache settings
9696 let response = await fetch (c .req .raw , {
9797 cf: {
@@ -103,13 +103,13 @@ app.all('*', async (c) => {
103103 cacheKey: someCustomKey ,
104104 },
105105 });
106-
106+
107107 // Reconstruct the Response object to make its headers mutable
108108 response = new Response (response .body , response );
109-
109+
110110 // Set cache control headers to cache on browser for 25 minutes
111111 response .headers .set (" Cache-Control" , " max-age=1500" );
112-
112+
113113 return response ;
114114});
115115
@@ -278,17 +278,17 @@ const app = new Hono<{ Bindings: Bindings }>();
278278app .all (' *' , async (c ) => {
279279 const originalUrl = c .req .url ;
280280 const url = new URL (originalUrl );
281-
281+
282282 // Randomly select a storage backend
283283 if (Math .random () < 0.5 ) {
284284 url .hostname = " example.s3.amazonaws.com" ;
285285 } else {
286286 url .hostname = " example.storage.googleapis.com" ;
287287 }
288-
288+
289289 // Create a new request to the selected backend
290290 const newRequest = new Request (url , c .req .raw );
291-
291+
292292 // Fetch using the original URL as the cache key
293293 return fetch (newRequest , {
294294 cf: { cacheKey: originalUrl },
0 commit comments