Closed BolajiAyodeji closed 5 years ago
Also if I go to /public
directory and open the build files directly, it works just fine, but once deployed it doesn't.
PS: I've cleared cache countless times
Sorry @BolajiAyodeji, I can't figure out what's your problem is.
But several days ago, I played with service worker and broken this theme with a cache-first strategy (see issue #101), then I fixed it with the network-first strategy in commit 5efbf8e49845f97b004c24d4bc16d54e6880763c.
If you have cloned that codebase that time, there will be a long-term cache staying in your browser, clear cache, unregister the service-worker.js and try again.
I think I have the latest service-workers
var cacheName = 'hugo-nuo-v5';
var filesToCache = [
'404.html',
'manifest.json',
'icons/icon-16x16.png',
'icons/icon-32x32.png',
'icons/icon-128x128.png',
'icons/icon-144x144.png',
'icons/icon-152x152.png',
'icons/icon-192x192.png',
'icons/icon-256x256.png',
'icons/icon-512x512.png',
'images/avatar.png',
'images/grey-prism.svg',
'images/qrcode.jpg',
'styles/main.min.css',
'styles/custom.min.css',
'scripts/index.min.js',
// Google fonts
'https://fonts.googleapis.com/css?family=Poppins:300,400,500',
// Iconfont
'https://at.alicdn.com/t/font_174169_qmgvd10zwbf.woff',
// smooth-scroll
'https://cdn.jsdelivr.net/npm/smooth-scroll@15.0.0/dist/smooth-scroll.min.js',
// MathJax
'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML',
'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js?V=2.7.5',
];
// Cache the application assets
self.addEventListener('install', event => {
event.waitUntil(caches.open(cacheName).then(cache => cache.addAll(filesToCache)));
});
// network first
self.addEventListener('fetch', event => {
event.respondWith(
caches.open(cacheName).then(function(cache) {
return fetch(event.request)
.then(function(response) {
if (response.status === 404) return caches.match('404.html');
cache.put(event.request, response.clone());
return response;
})
.catch(function() {
return caches.match(event.request);
});
}),
);
});
// cache-first
// If you want to use cache first, you should change cacheName manually
// self.addEventListener('fetch', event => {
// event.respondWith(
// caches
// .match(event.request)
// .then(response => {
// if (response) return response;
// return fetch(event.request);
// })
// .then(response => {
// if (response.status === 404) return caches.match('404.html');
// return caches.open(cacheName).then(cache => {
// cache.put(event.request.url, response.clone());
// return response;
// });
// })
// .catch(error => console.log('Error, ', error)),
// );
// });
// Delete outdated caches
self.addEventListener('activate', event => {
const cacheWhitelist = [cacheName];
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cacheName => {
if (cacheWhitelist.indexOf(cacheName) === -1) {
return caches.delete(cacheName);
}
}),
);
}),
);
});
Will netlify cache asset files, I didn't add a hash (fingerprint) to asset files in production, maybe it's a cache problem? Could you add the fingerprint to hugo pipes and build/deploy to netlify again? If it's really a cache problem, I will fix it tomorrow.
Let me try that.
Fingerprinting and SRI can be applied to any asset file using resources.Fingerpint which takes two arguments, the resource object and a hash function.
I'm I adding that to all files?
Will netlify cache asset files, I didn't add a hash (fingerprint) to asset files in production, maybe it's a cache problem? Could you add the fingerprint to hugo pipes and build/deploy to netlify again? If it's really a cache problem, I will fix it tomorrow.
Have you fixed?
Hi @BolajiAyodeji, haven't yet. I can't confirm what's the problem is, I said maybe cache problem, but maybe not.
I am sorry that I am not a netlify user, could you add fingerprinting with your CSS file then test on netlify?
I'm having issues with development and production mode. The site works fine as I want on localhost but once I run
hugo
and deploy to netlify, it doesn't work as it does on local.I've modified the avatar now, but it is still displaying the old one in production meanwhile it works fine on local, also my font. Everything works fine in local but once deployed, it's different!
What could be wrong?