how to cache webp images in service worker?
I am doing image minification and conversion to webp using gulp through the following code:
gulp.task('minify-images', function()jpg);
I am getting following error in console:
Do I need to make any changes to my service worker since the console error is pointing towards service worker??
self.addEventListener('install', function(event)
console.log("Service Worker installed");
event.waitUntil(
caches.open(staticCacheName).then(function(cache)
return cache.addAll([
'./',
'./index.html',
'./rt.html',
'./offline.html',
'./manifest.json',
// Remove rts.json from cache as data is coming from server.
'./css/styles.css',
'./img/1.jpg',
'./img/2.jpg',
'./img/3.jpg',
'./img/4.jpg',
'./img/5.jpg',
'./img/6.jpg',
'./img/7.jpg',
'./img/8.jpg',
'./img/9.jpg',
'./img/10.jpg',
'./img/marker-icon-2x-red.png',
'./img/marker-shadow.png',
'./img/offlinegiphy.gif',
'./img/icons/iconman.png',
'./img/icons/iconman-48x48.png',
'./img/icons/iconman-64x64.png',
'./img/icons/iconman-128x128.png',
'./img/icons/iconman-256x256.png',
'./img/icons/iconman-512x512.png',
'./js/dbhelper.js',
'./js/main.js',
'./js/rt_info.js',
'./register_sw.js',
'./serviceworker.js',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.css',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.js',
]);
)
);
console.log("cache successful");
);
I tried changing the extension to webp for jpg images but that also not worked.
I have a few queries :
- why I am getting the error for only jpg images is it because these images are fetching from the API?
- how to handle all image formats caching in service worker after gulp minification and conversions?
Please Help in sorting this out I am so confused here if you can point me to some good resources as well it will be great help !!
Edit 1:
Updated serviceworker.js code
`
const staticCacheName = 'rt-rws-v4';
var imgCache = 'rt-img';
var filesToCache=[
'./',
'./index.html',
'./rt.html',
'./offline.html',
'./manifest.json',
// Remove rt.json from cache as data is coming from server.
'./css/styles.css',
'./js/dbhelper.js',
'./js/main.js',
'./js/rt_info.js',
'./js/idb.js',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.css',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.js',
];
/**
* This block is invoked when install event is fired
*/
self.addEventListener('install', function(event)
event.waitUntil(
caches.open(staticCacheName).then(function(cache)
return cache.addAll(filesToCache);
)
);
);
// deletes old cache
self.addEventListener('activate', function(event)
// console.log("Service Worker activated");
event.waitUntil(
caches.keys().then(function(cacheNames)
return Promise.all(
cacheNames.filter(function(cacheName)
return cacheName.startsWith('rt-rws-') &&
cacheName != staticCacheName;
).map(function(cacheName)
return caches.delete(cacheName);
)
);
console.log("Old cache removed");
)
);
);
self.addEventListener('fetch', function(event) png);
/**
* @description Adds images to the imgCache
* @param string request
* @returns Response
*/
function cacheImages(request)
var storageUrl = new URL(request.url).pathname;
return caches.open(imgCache).then(function(cache)
return cache.match(storageUrl).then(function(response)
if (response) return response;
return fetch(request).then(function(networkResponse)
cache.put(storageUrl, networkResponse.clone());
return networkResponse;
);
);
);
/* // Inspect the accept header for WebP support
var supportsWebp = false;
if (event.request.headers.has('accept'))
supportsWebp = event.request.headers
.get('accept')
.includes('webp');
// If we support WebP
if (supportsWebp)
{
// Clone the request
var req = event.request.clone();
// Build the return URL
var returnUrl = req.url.substr(0, req.url.lastIndexOf(".")) + ".webp";
//console.log("Service Worker starting fetch"); */
`
No issues with gulp task successfully run and doing task
[09:10:50] Using gulpfile gulpfile.js
[09:10:50] Starting 'minify-images'...
[09:10:51] gulp-imagemin: Minified 18 image (saved 12.84 kB - 6.6%)
[09:10:51] Finished 'minify-images' after 108 ms
chrome headers
Request URL: http://localhost:8000/img/6
Request Method: GET Status Code: 404 Not Found (from ServiceWorker)
Remote Address: 127.0.0.1:8000
Referrer Policy:no-referrer-when-downgrade
Connection: keep-alive
Content-Length: 0
Date: Fri, 16 Nov 2018 13:43:03 GMT
server: ecstatic-3.2.2 Provisional headers are shown
Referer: http://localhost:8000/
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Mobile Safari/537.36
gulp service-worker bundling-and-minification webp gulp-imagemin
add a comment |
I am doing image minification and conversion to webp using gulp through the following code:
gulp.task('minify-images', function()jpg);
I am getting following error in console:
Do I need to make any changes to my service worker since the console error is pointing towards service worker??
self.addEventListener('install', function(event)
console.log("Service Worker installed");
event.waitUntil(
caches.open(staticCacheName).then(function(cache)
return cache.addAll([
'./',
'./index.html',
'./rt.html',
'./offline.html',
'./manifest.json',
// Remove rts.json from cache as data is coming from server.
'./css/styles.css',
'./img/1.jpg',
'./img/2.jpg',
'./img/3.jpg',
'./img/4.jpg',
'./img/5.jpg',
'./img/6.jpg',
'./img/7.jpg',
'./img/8.jpg',
'./img/9.jpg',
'./img/10.jpg',
'./img/marker-icon-2x-red.png',
'./img/marker-shadow.png',
'./img/offlinegiphy.gif',
'./img/icons/iconman.png',
'./img/icons/iconman-48x48.png',
'./img/icons/iconman-64x64.png',
'./img/icons/iconman-128x128.png',
'./img/icons/iconman-256x256.png',
'./img/icons/iconman-512x512.png',
'./js/dbhelper.js',
'./js/main.js',
'./js/rt_info.js',
'./register_sw.js',
'./serviceworker.js',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.css',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.js',
]);
)
);
console.log("cache successful");
);
I tried changing the extension to webp for jpg images but that also not worked.
I have a few queries :
- why I am getting the error for only jpg images is it because these images are fetching from the API?
- how to handle all image formats caching in service worker after gulp minification and conversions?
Please Help in sorting this out I am so confused here if you can point me to some good resources as well it will be great help !!
Edit 1:
Updated serviceworker.js code
`
const staticCacheName = 'rt-rws-v4';
var imgCache = 'rt-img';
var filesToCache=[
'./',
'./index.html',
'./rt.html',
'./offline.html',
'./manifest.json',
// Remove rt.json from cache as data is coming from server.
'./css/styles.css',
'./js/dbhelper.js',
'./js/main.js',
'./js/rt_info.js',
'./js/idb.js',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.css',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.js',
];
/**
* This block is invoked when install event is fired
*/
self.addEventListener('install', function(event)
event.waitUntil(
caches.open(staticCacheName).then(function(cache)
return cache.addAll(filesToCache);
)
);
);
// deletes old cache
self.addEventListener('activate', function(event)
// console.log("Service Worker activated");
event.waitUntil(
caches.keys().then(function(cacheNames)
return Promise.all(
cacheNames.filter(function(cacheName)
return cacheName.startsWith('rt-rws-') &&
cacheName != staticCacheName;
).map(function(cacheName)
return caches.delete(cacheName);
)
);
console.log("Old cache removed");
)
);
);
self.addEventListener('fetch', function(event) png);
/**
* @description Adds images to the imgCache
* @param string request
* @returns Response
*/
function cacheImages(request)
var storageUrl = new URL(request.url).pathname;
return caches.open(imgCache).then(function(cache)
return cache.match(storageUrl).then(function(response)
if (response) return response;
return fetch(request).then(function(networkResponse)
cache.put(storageUrl, networkResponse.clone());
return networkResponse;
);
);
);
/* // Inspect the accept header for WebP support
var supportsWebp = false;
if (event.request.headers.has('accept'))
supportsWebp = event.request.headers
.get('accept')
.includes('webp');
// If we support WebP
if (supportsWebp)
{
// Clone the request
var req = event.request.clone();
// Build the return URL
var returnUrl = req.url.substr(0, req.url.lastIndexOf(".")) + ".webp";
//console.log("Service Worker starting fetch"); */
`
No issues with gulp task successfully run and doing task
[09:10:50] Using gulpfile gulpfile.js
[09:10:50] Starting 'minify-images'...
[09:10:51] gulp-imagemin: Minified 18 image (saved 12.84 kB - 6.6%)
[09:10:51] Finished 'minify-images' after 108 ms
chrome headers
Request URL: http://localhost:8000/img/6
Request Method: GET Status Code: 404 Not Found (from ServiceWorker)
Remote Address: 127.0.0.1:8000
Referrer Policy:no-referrer-when-downgrade
Connection: keep-alive
Content-Length: 0
Date: Fri, 16 Nov 2018 13:43:03 GMT
server: ecstatic-3.2.2 Provisional headers are shown
Referer: http://localhost:8000/
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Mobile Safari/537.36
gulp service-worker bundling-and-minification webp gulp-imagemin
you have .jpg and .webp files existent in/img
directory? what exactly is pointing towards service worker in the console error? and i would say it's better to not cache./register_sw.js
and./serviceworker.js
with the service-worker itself, else you can't update
– André Kelling
Nov 14 '18 at 15:43
@AndréKelling there is no issue with image optimization and conversion to webp all images are optimized and converted to webp and stored in dist folder...I updated my service worker code not caching service worker files anymore..for now removing manually catching each images I am working on updating service worker code for caching images in the service via function i think that will work if issue still persist i will update the question here
– PN10
Nov 15 '18 at 16:36
@AndréKelling Updated service worker code but the issue still persist gulp minify-images task is running successfully so I guess the issue is with service worker only added headers information still not able to understand the cause ...Please help
– PN10
Nov 16 '18 at 13:55
you said they are stored indist
folder: do you mean theimg
folder? can you check whats in the cache? in chrome dev toolsApplication
>Cache Storage
>Name of your cache
– André Kelling
Nov 16 '18 at 14:46
@AndréKelling thanks for your help I figured out !! It's working now.
– PN10
Nov 19 '18 at 8:23
add a comment |
I am doing image minification and conversion to webp using gulp through the following code:
gulp.task('minify-images', function()jpg);
I am getting following error in console:
Do I need to make any changes to my service worker since the console error is pointing towards service worker??
self.addEventListener('install', function(event)
console.log("Service Worker installed");
event.waitUntil(
caches.open(staticCacheName).then(function(cache)
return cache.addAll([
'./',
'./index.html',
'./rt.html',
'./offline.html',
'./manifest.json',
// Remove rts.json from cache as data is coming from server.
'./css/styles.css',
'./img/1.jpg',
'./img/2.jpg',
'./img/3.jpg',
'./img/4.jpg',
'./img/5.jpg',
'./img/6.jpg',
'./img/7.jpg',
'./img/8.jpg',
'./img/9.jpg',
'./img/10.jpg',
'./img/marker-icon-2x-red.png',
'./img/marker-shadow.png',
'./img/offlinegiphy.gif',
'./img/icons/iconman.png',
'./img/icons/iconman-48x48.png',
'./img/icons/iconman-64x64.png',
'./img/icons/iconman-128x128.png',
'./img/icons/iconman-256x256.png',
'./img/icons/iconman-512x512.png',
'./js/dbhelper.js',
'./js/main.js',
'./js/rt_info.js',
'./register_sw.js',
'./serviceworker.js',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.css',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.js',
]);
)
);
console.log("cache successful");
);
I tried changing the extension to webp for jpg images but that also not worked.
I have a few queries :
- why I am getting the error for only jpg images is it because these images are fetching from the API?
- how to handle all image formats caching in service worker after gulp minification and conversions?
Please Help in sorting this out I am so confused here if you can point me to some good resources as well it will be great help !!
Edit 1:
Updated serviceworker.js code
`
const staticCacheName = 'rt-rws-v4';
var imgCache = 'rt-img';
var filesToCache=[
'./',
'./index.html',
'./rt.html',
'./offline.html',
'./manifest.json',
// Remove rt.json from cache as data is coming from server.
'./css/styles.css',
'./js/dbhelper.js',
'./js/main.js',
'./js/rt_info.js',
'./js/idb.js',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.css',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.js',
];
/**
* This block is invoked when install event is fired
*/
self.addEventListener('install', function(event)
event.waitUntil(
caches.open(staticCacheName).then(function(cache)
return cache.addAll(filesToCache);
)
);
);
// deletes old cache
self.addEventListener('activate', function(event)
// console.log("Service Worker activated");
event.waitUntil(
caches.keys().then(function(cacheNames)
return Promise.all(
cacheNames.filter(function(cacheName)
return cacheName.startsWith('rt-rws-') &&
cacheName != staticCacheName;
).map(function(cacheName)
return caches.delete(cacheName);
)
);
console.log("Old cache removed");
)
);
);
self.addEventListener('fetch', function(event) png);
/**
* @description Adds images to the imgCache
* @param string request
* @returns Response
*/
function cacheImages(request)
var storageUrl = new URL(request.url).pathname;
return caches.open(imgCache).then(function(cache)
return cache.match(storageUrl).then(function(response)
if (response) return response;
return fetch(request).then(function(networkResponse)
cache.put(storageUrl, networkResponse.clone());
return networkResponse;
);
);
);
/* // Inspect the accept header for WebP support
var supportsWebp = false;
if (event.request.headers.has('accept'))
supportsWebp = event.request.headers
.get('accept')
.includes('webp');
// If we support WebP
if (supportsWebp)
{
// Clone the request
var req = event.request.clone();
// Build the return URL
var returnUrl = req.url.substr(0, req.url.lastIndexOf(".")) + ".webp";
//console.log("Service Worker starting fetch"); */
`
No issues with gulp task successfully run and doing task
[09:10:50] Using gulpfile gulpfile.js
[09:10:50] Starting 'minify-images'...
[09:10:51] gulp-imagemin: Minified 18 image (saved 12.84 kB - 6.6%)
[09:10:51] Finished 'minify-images' after 108 ms
chrome headers
Request URL: http://localhost:8000/img/6
Request Method: GET Status Code: 404 Not Found (from ServiceWorker)
Remote Address: 127.0.0.1:8000
Referrer Policy:no-referrer-when-downgrade
Connection: keep-alive
Content-Length: 0
Date: Fri, 16 Nov 2018 13:43:03 GMT
server: ecstatic-3.2.2 Provisional headers are shown
Referer: http://localhost:8000/
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Mobile Safari/537.36
gulp service-worker bundling-and-minification webp gulp-imagemin
I am doing image minification and conversion to webp using gulp through the following code:
gulp.task('minify-images', function()jpg);
I am getting following error in console:
Do I need to make any changes to my service worker since the console error is pointing towards service worker??
self.addEventListener('install', function(event)
console.log("Service Worker installed");
event.waitUntil(
caches.open(staticCacheName).then(function(cache)
return cache.addAll([
'./',
'./index.html',
'./rt.html',
'./offline.html',
'./manifest.json',
// Remove rts.json from cache as data is coming from server.
'./css/styles.css',
'./img/1.jpg',
'./img/2.jpg',
'./img/3.jpg',
'./img/4.jpg',
'./img/5.jpg',
'./img/6.jpg',
'./img/7.jpg',
'./img/8.jpg',
'./img/9.jpg',
'./img/10.jpg',
'./img/marker-icon-2x-red.png',
'./img/marker-shadow.png',
'./img/offlinegiphy.gif',
'./img/icons/iconman.png',
'./img/icons/iconman-48x48.png',
'./img/icons/iconman-64x64.png',
'./img/icons/iconman-128x128.png',
'./img/icons/iconman-256x256.png',
'./img/icons/iconman-512x512.png',
'./js/dbhelper.js',
'./js/main.js',
'./js/rt_info.js',
'./register_sw.js',
'./serviceworker.js',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.css',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.js',
]);
)
);
console.log("cache successful");
);
I tried changing the extension to webp for jpg images but that also not worked.
I have a few queries :
- why I am getting the error for only jpg images is it because these images are fetching from the API?
- how to handle all image formats caching in service worker after gulp minification and conversions?
Please Help in sorting this out I am so confused here if you can point me to some good resources as well it will be great help !!
Edit 1:
Updated serviceworker.js code
`
const staticCacheName = 'rt-rws-v4';
var imgCache = 'rt-img';
var filesToCache=[
'./',
'./index.html',
'./rt.html',
'./offline.html',
'./manifest.json',
// Remove rt.json from cache as data is coming from server.
'./css/styles.css',
'./js/dbhelper.js',
'./js/main.js',
'./js/rt_info.js',
'./js/idb.js',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.css',
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.js',
];
/**
* This block is invoked when install event is fired
*/
self.addEventListener('install', function(event)
event.waitUntil(
caches.open(staticCacheName).then(function(cache)
return cache.addAll(filesToCache);
)
);
);
// deletes old cache
self.addEventListener('activate', function(event)
// console.log("Service Worker activated");
event.waitUntil(
caches.keys().then(function(cacheNames)
return Promise.all(
cacheNames.filter(function(cacheName)
return cacheName.startsWith('rt-rws-') &&
cacheName != staticCacheName;
).map(function(cacheName)
return caches.delete(cacheName);
)
);
console.log("Old cache removed");
)
);
);
self.addEventListener('fetch', function(event) png);
/**
* @description Adds images to the imgCache
* @param string request
* @returns Response
*/
function cacheImages(request)
var storageUrl = new URL(request.url).pathname;
return caches.open(imgCache).then(function(cache)
return cache.match(storageUrl).then(function(response)
if (response) return response;
return fetch(request).then(function(networkResponse)
cache.put(storageUrl, networkResponse.clone());
return networkResponse;
);
);
);
/* // Inspect the accept header for WebP support
var supportsWebp = false;
if (event.request.headers.has('accept'))
supportsWebp = event.request.headers
.get('accept')
.includes('webp');
// If we support WebP
if (supportsWebp)
{
// Clone the request
var req = event.request.clone();
// Build the return URL
var returnUrl = req.url.substr(0, req.url.lastIndexOf(".")) + ".webp";
//console.log("Service Worker starting fetch"); */
`
No issues with gulp task successfully run and doing task
[09:10:50] Using gulpfile gulpfile.js
[09:10:50] Starting 'minify-images'...
[09:10:51] gulp-imagemin: Minified 18 image (saved 12.84 kB - 6.6%)
[09:10:51] Finished 'minify-images' after 108 ms
chrome headers
Request URL: http://localhost:8000/img/6
Request Method: GET Status Code: 404 Not Found (from ServiceWorker)
Remote Address: 127.0.0.1:8000
Referrer Policy:no-referrer-when-downgrade
Connection: keep-alive
Content-Length: 0
Date: Fri, 16 Nov 2018 13:43:03 GMT
server: ecstatic-3.2.2 Provisional headers are shown
Referer: http://localhost:8000/
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Mobile Safari/537.36
gulp service-worker bundling-and-minification webp gulp-imagemin
gulp service-worker bundling-and-minification webp gulp-imagemin
edited Nov 16 '18 at 13:58
PN10
asked Nov 1 '18 at 18:31
PN10PN10
1,31221424
1,31221424
you have .jpg and .webp files existent in/img
directory? what exactly is pointing towards service worker in the console error? and i would say it's better to not cache./register_sw.js
and./serviceworker.js
with the service-worker itself, else you can't update
– André Kelling
Nov 14 '18 at 15:43
@AndréKelling there is no issue with image optimization and conversion to webp all images are optimized and converted to webp and stored in dist folder...I updated my service worker code not caching service worker files anymore..for now removing manually catching each images I am working on updating service worker code for caching images in the service via function i think that will work if issue still persist i will update the question here
– PN10
Nov 15 '18 at 16:36
@AndréKelling Updated service worker code but the issue still persist gulp minify-images task is running successfully so I guess the issue is with service worker only added headers information still not able to understand the cause ...Please help
– PN10
Nov 16 '18 at 13:55
you said they are stored indist
folder: do you mean theimg
folder? can you check whats in the cache? in chrome dev toolsApplication
>Cache Storage
>Name of your cache
– André Kelling
Nov 16 '18 at 14:46
@AndréKelling thanks for your help I figured out !! It's working now.
– PN10
Nov 19 '18 at 8:23
add a comment |
you have .jpg and .webp files existent in/img
directory? what exactly is pointing towards service worker in the console error? and i would say it's better to not cache./register_sw.js
and./serviceworker.js
with the service-worker itself, else you can't update
– André Kelling
Nov 14 '18 at 15:43
@AndréKelling there is no issue with image optimization and conversion to webp all images are optimized and converted to webp and stored in dist folder...I updated my service worker code not caching service worker files anymore..for now removing manually catching each images I am working on updating service worker code for caching images in the service via function i think that will work if issue still persist i will update the question here
– PN10
Nov 15 '18 at 16:36
@AndréKelling Updated service worker code but the issue still persist gulp minify-images task is running successfully so I guess the issue is with service worker only added headers information still not able to understand the cause ...Please help
– PN10
Nov 16 '18 at 13:55
you said they are stored indist
folder: do you mean theimg
folder? can you check whats in the cache? in chrome dev toolsApplication
>Cache Storage
>Name of your cache
– André Kelling
Nov 16 '18 at 14:46
@AndréKelling thanks for your help I figured out !! It's working now.
– PN10
Nov 19 '18 at 8:23
you have .jpg and .webp files existent in
/img
directory? what exactly is pointing towards service worker in the console error? and i would say it's better to not cache ./register_sw.js
and ./serviceworker.js
with the service-worker itself, else you can't update– André Kelling
Nov 14 '18 at 15:43
you have .jpg and .webp files existent in
/img
directory? what exactly is pointing towards service worker in the console error? and i would say it's better to not cache ./register_sw.js
and ./serviceworker.js
with the service-worker itself, else you can't update– André Kelling
Nov 14 '18 at 15:43
@AndréKelling there is no issue with image optimization and conversion to webp all images are optimized and converted to webp and stored in dist folder...I updated my service worker code not caching service worker files anymore..for now removing manually catching each images I am working on updating service worker code for caching images in the service via function i think that will work if issue still persist i will update the question here
– PN10
Nov 15 '18 at 16:36
@AndréKelling there is no issue with image optimization and conversion to webp all images are optimized and converted to webp and stored in dist folder...I updated my service worker code not caching service worker files anymore..for now removing manually catching each images I am working on updating service worker code for caching images in the service via function i think that will work if issue still persist i will update the question here
– PN10
Nov 15 '18 at 16:36
@AndréKelling Updated service worker code but the issue still persist gulp minify-images task is running successfully so I guess the issue is with service worker only added headers information still not able to understand the cause ...Please help
– PN10
Nov 16 '18 at 13:55
@AndréKelling Updated service worker code but the issue still persist gulp minify-images task is running successfully so I guess the issue is with service worker only added headers information still not able to understand the cause ...Please help
– PN10
Nov 16 '18 at 13:55
you said they are stored in
dist
folder: do you mean the img
folder? can you check whats in the cache? in chrome dev tools Application
> Cache Storage
> Name of your cache
– André Kelling
Nov 16 '18 at 14:46
you said they are stored in
dist
folder: do you mean the img
folder? can you check whats in the cache? in chrome dev tools Application
> Cache Storage
> Name of your cache
– André Kelling
Nov 16 '18 at 14:46
@AndréKelling thanks for your help I figured out !! It's working now.
– PN10
Nov 19 '18 at 8:23
@AndréKelling thanks for your help I figured out !! It's working now.
– PN10
Nov 19 '18 at 8:23
add a comment |
1 Answer
1
active
oldest
votes
Your compressed webp files are stored in dist/img
but should get saved in img
directory.
Because they are requested from img
.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53107308%2fhow-to-cache-webp-images-in-service-worker%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your compressed webp files are stored in dist/img
but should get saved in img
directory.
Because they are requested from img
.
add a comment |
Your compressed webp files are stored in dist/img
but should get saved in img
directory.
Because they are requested from img
.
add a comment |
Your compressed webp files are stored in dist/img
but should get saved in img
directory.
Because they are requested from img
.
Your compressed webp files are stored in dist/img
but should get saved in img
directory.
Because they are requested from img
.
edited Nov 19 '18 at 10:56
answered Nov 19 '18 at 10:18
André KellingAndré Kelling
299211
299211
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53107308%2fhow-to-cache-webp-images-in-service-worker%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you have .jpg and .webp files existent in
/img
directory? what exactly is pointing towards service worker in the console error? and i would say it's better to not cache./register_sw.js
and./serviceworker.js
with the service-worker itself, else you can't update– André Kelling
Nov 14 '18 at 15:43
@AndréKelling there is no issue with image optimization and conversion to webp all images are optimized and converted to webp and stored in dist folder...I updated my service worker code not caching service worker files anymore..for now removing manually catching each images I am working on updating service worker code for caching images in the service via function i think that will work if issue still persist i will update the question here
– PN10
Nov 15 '18 at 16:36
@AndréKelling Updated service worker code but the issue still persist gulp minify-images task is running successfully so I guess the issue is with service worker only added headers information still not able to understand the cause ...Please help
– PN10
Nov 16 '18 at 13:55
you said they are stored in
dist
folder: do you mean theimg
folder? can you check whats in the cache? in chrome dev toolsApplication
>Cache Storage
>Name of your cache
– André Kelling
Nov 16 '18 at 14:46
@AndréKelling thanks for your help I figured out !! It's working now.
– PN10
Nov 19 '18 at 8:23