My PWA runs on Firebase. My image files are hosted on Firebase Storage. I noticed that my browser does not save the cache for files downloaded from the storage system. The browser requests files for each page refresh. This causes unnecessary delay and traffic.
My JS script downloads files via the Firebase Storage download link, for example: https://firebasestorage.googleapis.com/v0/b/discipulado-7b14b.appspot.com/o/book3.png?alt=media&token=65b2cde7-c8a4 -45da-a743-401759663c17 .
Can I cache these requests?
UPDATE
, Firebase Storage . . ?
cacheControl for Storage: https://firebase.google.com/docs/reference/js/firebase.storage.SettableMetadata#cacheControl
cacheControl
, Firebase CLI . , Cache-Control 2 , .json.
https://firebase.google.com/docs/hosting/full-config#headers
, . , , , ..
, - ( , )
, , workbox cacheFirst . , , .
cacheFirst
, Firebase, , cacheControl Firebase Hosting Cache-Control .
Cache-Control
Serviceworker .
URL .
, .
-
cacheUrl = url.origin + url.pathname.substr(0, url.pathname.length - urlPath.length) + urlPath;
cache.put(cacheUrl, response);
storageRef.updateMetadata(yourMetadata) , .
storageRef.updateMetadata(yourMetadata)
https://firebase.google.com/docs/storage/web/file-metadata#update_file_metadata
or
storageRef.put(file, yourMetadata)
https://firebase.google.com/docs/storage/web/upload-files#upload_files
Source: https://habr.com/ru/post/1677729/More articles:iterate over array elements as strings and convert them to php submatrices - arraysDelphi Tokio IDE - any way to configure? - ideError converting pandoc document with error 67 - htmlCreating overlay 3D maps on google maps - javascriptWhat is the difference between a tensor flow in a spark discharge with a distributed tensor flow of 1.0 by default? - deep-learningwhy the lambda expression does not write `.class`, but the inner do class is javaFirebase file system file structure - firebasePandas: how to group by character and take the average value for each n lines - pythonПоиск семени функции rand() TI-84 - algorithmThe correct approach to using MethodHandleProxies - javaAll Articles