Added some time based cache bursting
This commit is contained in:
parent
e2440dcbbc
commit
5303b7f4de
@ -11,7 +11,7 @@
|
|||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
const CACHE_VERSION = { 'version': '0.0.910' };
|
const CACHE_VERSION = { 'version': '0.0.918' };
|
||||||
const PRECACHE = `jubileeData-${CACHE_VERSION.version}`;
|
const PRECACHE = `jubileeData-${CACHE_VERSION.version}`;
|
||||||
const RUNTIME = 'runtime';
|
const RUNTIME = 'runtime';
|
||||||
|
|
||||||
@ -124,15 +124,26 @@ self.addEventListener('fetch', event => {
|
|||||||
);
|
);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/* if (event.request.url.startsWith(self.location.origin)) {
|
if (event.request.url.startsWith(self.location.origin)) {
|
||||||
console.log('One of our requests..');
|
console.log('!!', event.request);
|
||||||
|
|
||||||
|
/* event.respondWith(
|
||||||
event.respondWith(
|
|
||||||
caches.open(RUNTIME).then(function(cache) {
|
caches.open(RUNTIME).then(function(cache) {
|
||||||
return cache.match(event.request).then(function (response) {
|
return cache.match(event.request).then(function (response) {
|
||||||
console.log('£', response);
|
console.log('£', response);
|
||||||
|
|
||||||
|
return response || fetch(event.request).then(function(response) {
|
||||||
|
cache.put(event.request, response.clone());
|
||||||
|
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);*/
|
||||||
|
|
||||||
|
event.respondWith(
|
||||||
|
caches.open(RUNTIME).then(function(cache) {
|
||||||
|
return cache.match(event.request).then(function (response) {
|
||||||
return response || fetch(event.request).then(function(response) {
|
return response || fetch(event.request).then(function(response) {
|
||||||
cache.put(event.request, response.clone());
|
cache.put(event.request, response.clone());
|
||||||
|
|
||||||
@ -141,7 +152,7 @@ self.addEventListener('fetch', event => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
if (event.request.url.startsWith('https://maps.googleapis.com')) {
|
if (event.request.url.startsWith('https://maps.googleapis.com')) {
|
||||||
const url = new URL(event.request.url);
|
const url = new URL(event.request.url);
|
||||||
|
@ -4,7 +4,7 @@ const Backbone = require('backbone');
|
|||||||
const request = require('request');
|
const request = require('request');
|
||||||
const { get } = require('lodash');
|
const { get } = require('lodash');
|
||||||
const { reduceNearby } = require('./libs/reducers');
|
const { reduceNearby } = require('./libs/reducers');
|
||||||
const { toHour } = require('./libs/utils');
|
const { toHour, hourFloor } = require('./libs/utils');
|
||||||
const TimeFormat = require('hh-mm-ss');
|
const TimeFormat = require('hh-mm-ss');
|
||||||
|
|
||||||
const { FSDetailView } = require('./Foursquare');
|
const { FSDetailView } = require('./Foursquare');
|
||||||
@ -63,6 +63,7 @@ const NearbyModel = Backbone.Model.extend({
|
|||||||
|
|
||||||
url.searchParams.append('ll', llFixed);
|
url.searchParams.append('ll', llFixed);
|
||||||
url.searchParams.append('section', section);
|
url.searchParams.append('section', section);
|
||||||
|
url.searchParams.append('w', hourFloor());
|
||||||
|
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
@ -3,7 +3,7 @@ const _ = require('underscore');
|
|||||||
const Backbone = require('backbone');
|
const Backbone = require('backbone');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
const { get, isEmpty } = require('lodash');
|
const { get, isEmpty } = require('lodash');
|
||||||
const { maybePluralize } = require('./libs/utils');
|
const { maybePluralize, hourFloor } = require('./libs/utils');
|
||||||
const templates = require('./libs/templates');
|
const templates = require('./libs/templates');
|
||||||
|
|
||||||
const ByMeModel = Backbone.Model.extend({
|
const ByMeModel = Backbone.Model.extend({
|
||||||
|
@ -6,7 +6,7 @@ const fecha = require('fecha');
|
|||||||
const TimeFormat = require('hh-mm-ss');
|
const TimeFormat = require('hh-mm-ss');
|
||||||
const { get } = require('lodash');
|
const { get } = require('lodash');
|
||||||
const { reduceOpenWeather } = require('./libs/reducers');
|
const { reduceOpenWeather } = require('./libs/reducers');
|
||||||
const { distance, toHour } = require('./libs/utils');
|
const { distance, toHour, hourFloor } = require('./libs/utils');
|
||||||
|
|
||||||
const WeatherAlertModel = Backbone.Model.extend({
|
const WeatherAlertModel = Backbone.Model.extend({
|
||||||
'defaults': function (obj) {
|
'defaults': function (obj) {
|
||||||
@ -62,7 +62,8 @@ const WeatherAlertModel = Backbone.Model.extend({
|
|||||||
'url': `${window.loc}/weatheralert`,
|
'url': `${window.loc}/weatheralert`,
|
||||||
'method': 'GET',
|
'method': 'GET',
|
||||||
'qs': {
|
'qs': {
|
||||||
'll': llFixed
|
'll': llFixed,
|
||||||
|
'w' : hourFloor()
|
||||||
}
|
}
|
||||||
}, function (err, res, body) {
|
}, function (err, res, body) {
|
||||||
console.log('statusCode', res.statusCode);
|
console.log('statusCode', res.statusCode);
|
||||||
@ -118,7 +119,7 @@ const WeatherAlertView = Backbone.View.extend({
|
|||||||
this.$title = $('#weatherAlertTitle');
|
this.$title = $('#weatherAlertTitle');
|
||||||
|
|
||||||
// this.model.bind('change', this.render, this);
|
// this.model.bind('change', this.render, this);
|
||||||
this.location.bind('change:llShort', this.updateLocation, this);
|
this.location.bind('change:llFixed', this.updateLocation, this);
|
||||||
this.model.bind('change:alert', this.render, this);
|
this.model.bind('change:alert', this.render, this);
|
||||||
this.eventBus.on('focused', this.focused, this);
|
this.eventBus.on('focused', this.focused, this);
|
||||||
},
|
},
|
||||||
@ -143,8 +144,8 @@ const WeatherAlertView = Backbone.View.extend({
|
|||||||
console.log('changedAttributes:', this.location.changedAttributes());
|
console.log('changedAttributes:', this.location.changedAttributes());
|
||||||
|
|
||||||
if (l.has('atHome')) {
|
if (l.has('atHome')) {
|
||||||
const llShort = l.get('llShort');
|
const llFixed = l.get('llFixed');
|
||||||
this.model.set('ll', llShort);
|
this.model.set('ll', llFixed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
console.log('>> Weather No location yet');
|
console.log('>> Weather No location yet');
|
||||||
|
@ -51,7 +51,7 @@ function toHour(extra = 0) {
|
|||||||
function hourFloor() {
|
function hourFloor() {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
return (~~(now.getTime() / 3600000) * 3600000);
|
return parseInt(~~(now.getTime() / 3600000) * 3600000, 10).toString(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
function distance(lat1, lon1, lat2, lon2) {
|
function distance(lat1, lon1, lat2, lon2) {
|
||||||
|
Loading…
Reference in New Issue
Block a user