Skip to content

Commit

Permalink
Cache and speed improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ALEEF02 committed Mar 2, 2020
1 parent 549e018 commit 5002bd0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 42 deletions.
15 changes: 7 additions & 8 deletions about.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Lake Forest Weather - About</title>
<link http-equiv="Cache-control" content="max-age=31536000" rel="stylesheet" type="text/css" href="about.css">
<link async" rel="stylesheet" type="text/css" href="about.css">
<link rel="preconnect" href="https://www.google-analytics.com">
<link rel="preconnect" href="https://pagead2.googlesyndication.com">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand All @@ -17,7 +17,7 @@
<link rel="apple-touch-startup-image" href="weatherIcons/apple-touch-icon.png">
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="icon" sizes="16x16 32x32" href="favicon.ico">
<script async src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script async src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-52495574-19"></script>
<script>
Expand Down Expand Up @@ -46,12 +46,7 @@
} else {
console.log('Browser does not support service worker');
}
</script>
<!-- Adblock Detection -->
<div id="bKSMcyXAlDun">
Hi there. Thank you for choosing LFWeather as your weather provider. I run this website, ad-free and free of charge, with my motivation being the growth of the user experience. While I plan never to serve ads, your adblocker prohibits Google Analytics, which I use to track site usage. By disabling your adblocker, I can better understand and improve the user experience. I will NEVER sell any data collected. Thank you!
</div>
<script>

document.addEventListener('DOMContentLoaded', init, false);

function init(){
Expand Down Expand Up @@ -83,6 +78,10 @@
});
}
</script>
<!-- Adblock Detection -->
<div id="bKSMcyXAlDun">
Hi there. Thank you for choosing LFWeather as your weather provider. I run this website, ad-free and free of charge, with my motivation being the growth of the user experience. While I plan never to serve ads, your adblocker prohibits Google Analytics, which I use to track site usage. By disabling your adblocker, I can better understand and improve the user experience. I will NEVER sell any data collected. Thank you!
</div>
</head>
<body>
<h1>About</h1>
Expand Down
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Lake Forest Weather - Home</title>
<link rel="stylesheet" type="text/css" href="normalize.css">
<link async rel="stylesheet" type="text/css" href="normalize.css">
<link rel="preconnect" href="https://www.google-analytics.com">
<link rel="preconnect" href="https://www.gstatic.com">
<link rel="preconnect" href="https://pagead2.googlesyndication.com">
Expand All @@ -20,7 +20,7 @@
<link rel="apple-touch-startup-image" href="weatherIcons/apple-touch-icon.png">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<link rel="icon" sizes="16x16 32x32" href="favicon.ico">
<script async src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script async src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-52495574-19"></script>
<script defer src="https://www.gstatic.com/firebasejs/5.8.1/firebase-app.js"></script>
<script defer src="https://www.gstatic.com/firebasejs/5.8.1/firebase-database.js"></script>
Expand Down Expand Up @@ -64,7 +64,7 @@
}
</script>
<script async type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="main.js"></script>
<script async type="text/javascript" src="main.js"></script>
<script defer type="text/javascript" src="resizeListen.js"></script>
<!-- Adblock Detection -->
<div id="bKSMcyXAlDun">
Expand Down Expand Up @@ -410,8 +410,8 @@ <h3>Radar</h3>
</div>
<div class="credits">
<p>
Version 3.7.0:
<a href="https://github.com/ALEEF02/lfweather/releases/tag/v3.7.0" id="changelogLink" onclick="trackOutboundLink('https://github.com/ALEEF02/lfweather/releases/tag/v3.7.0'); return false;">
Version 3.7.1:
<a href="https://github.com/ALEEF02/lfweather/releases/tag/v3.7.1" id="changelogLink" onclick="trackOutboundLink('https://github.com/ALEEF02/lfweather/releases/tag/v3.7.1'); return false;">
Changelog
</a>
</p>
Expand Down
42 changes: 13 additions & 29 deletions service-worker.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
const PRECACHE = 'precache-v7';
const RUNTIME = 'runtime-v7';
const PRECACHE = 'precache-v3.7.1';
const RUNTIME = 'runtime-v3.7.1';

// A list of local resources we always want to be cached.
const PRECACHE_URLS = [
'about.html'
'/about.html',
'/main.js',
'/resizeListen,js',
'/about.css',
'/normalize.css',
'/weatherIcons/sunny.png',
'/weatherIcons/partlyCloudy.png',
'/weatherIcons/cloudy.png',
'/weatherIcons/rainy.png',
'/weatherIcons/thunderStorm.png'
];

// The install handler takes care of precaching the resources we always need.
Expand All @@ -29,32 +38,7 @@ self.addEventListener('activate', event => {
);
});

// The fetch handler serves responses for same-origin resources from a cache.
// If no response is found, it populates the runtime cache with the response
// from the network before returning it to the page.

/*self.addEventListener('fetch', event => {
// Skip cross-origin requests, like those for Google Analytics.
if (event.request.url.startsWith(self.location.origin)) {
event.respondWith(
caches.match(event.request).then(cachedResponse => {
if (cachedResponse) {
return cachedResponse;
}
return caches.open(RUNTIME).then(cache => {
return fetch(event.request).then(response => {
// Put a copy of the response in the runtime cache.
return cache.put(event.request, response.clone()).then(() => {
return response;
});
});
});
})
);
}
});*/

// The fetch handler serves cached assets if available, otherwise fetches them from the server
self.addEventListener('fetch', function(event) {
if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin') {
return;
Expand Down

0 comments on commit 5002bd0

Please sign in to comment.