Added some time based cache bursting
This commit is contained in:
parent
b306c16424
commit
54da46e8bf
@ -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.895' };
|
const CACHE_VERSION = { 'version': '0.0.906' };
|
||||||
const PRECACHE = `jubileeData-${CACHE_VERSION.version}`;
|
const PRECACHE = `jubileeData-${CACHE_VERSION.version}`;
|
||||||
const RUNTIME = 'runtime';
|
const RUNTIME = 'runtime';
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ const request = require('request');
|
|||||||
const { get } = require('lodash');
|
const { get } = require('lodash');
|
||||||
const { reduceEuronews } = require('./libs/reducers');
|
const { reduceEuronews } = require('./libs/reducers');
|
||||||
const TimeFormat = require('hh-mm-ss');
|
const TimeFormat = require('hh-mm-ss');
|
||||||
|
const { hourFloor } = require('./libs/utils');
|
||||||
|
|
||||||
const NewsItem = Backbone.Model.extend({
|
const NewsItem = Backbone.Model.extend({
|
||||||
|
|
||||||
@ -62,7 +63,8 @@ const NewsModel = Backbone.Model.extend({
|
|||||||
request({
|
request({
|
||||||
'url': `${window.loc}/news`,
|
'url': `${window.loc}/news`,
|
||||||
'method': 'GET', 'qs': {
|
'method': 'GET', 'qs': {
|
||||||
'limit': 10
|
'limit': 10,
|
||||||
|
'w' : hourFloor()
|
||||||
}
|
}
|
||||||
}, function(err, res, body) {
|
}, function(err, res, body) {
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -5,6 +5,7 @@ const request = require('request');
|
|||||||
const { get } = require('lodash');
|
const { get } = require('lodash');
|
||||||
const { reduceEuronews } = require('./libs/reducers');
|
const { reduceEuronews } = require('./libs/reducers');
|
||||||
const { createPanel, addPanel } = require('./libs/panel');
|
const { createPanel, addPanel } = require('./libs/panel');
|
||||||
|
const { hourFloor } = require('./libs/utils');
|
||||||
|
|
||||||
const NewsItem = Backbone.Model.extend({
|
const NewsItem = Backbone.Model.extend({
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ const NewsListModel = Backbone.Model.extend({
|
|||||||
'url': `${window.loc}/news`,
|
'url': `${window.loc}/news`,
|
||||||
'method': 'GET', 'qs': {
|
'method': 'GET', 'qs': {
|
||||||
|
|
||||||
|
'w' : hourFloor()
|
||||||
}
|
}
|
||||||
}, function(err, res, body) {
|
}, function(err, res, body) {
|
||||||
if (err)
|
if (err)
|
||||||
@ -122,7 +124,7 @@ const NewsListView = Backbone.View.extend({
|
|||||||
|
|
||||||
}, 'doClick': function(d) {
|
}, 'doClick': function(d) {
|
||||||
// console.log('Do click', d);
|
// console.log('Do click', d);
|
||||||
let self = this;
|
const self = this;
|
||||||
const id = get(d, 'currentTarget.dataset.guid', '');
|
const id = get(d, 'currentTarget.dataset.guid', '');
|
||||||
console.log(id);
|
console.log(id);
|
||||||
this.eventBus.trigger('showNews', id, () => {
|
this.eventBus.trigger('showNews', id, () => {
|
||||||
|
@ -4,6 +4,7 @@ const Backbone = require('backbone');
|
|||||||
const request = require('request');
|
const request = require('request');
|
||||||
const { get, isEmpty } = require('lodash');
|
const { get, isEmpty } = require('lodash');
|
||||||
const { createPanel, addPanel } = require('./libs/panel');
|
const { createPanel, addPanel } = require('./libs/panel');
|
||||||
|
const { hourFloor } = require('./libs/utils');
|
||||||
|
|
||||||
const NewsCardModel = Backbone.Model.extend({
|
const NewsCardModel = Backbone.Model.extend({
|
||||||
'initialize': function() {
|
'initialize': function() {
|
||||||
@ -19,7 +20,8 @@ const NewsCardModel = Backbone.Model.extend({
|
|||||||
'url': `${window.loc}/article`,
|
'url': `${window.loc}/article`,
|
||||||
'method': 'GET',
|
'method': 'GET',
|
||||||
'qs': {
|
'qs': {
|
||||||
'guid': guid
|
'guid': guid,
|
||||||
|
'w' : hourFloor()
|
||||||
}
|
}
|
||||||
}, function(err, res, body) {
|
}, function(err, res, body) {
|
||||||
console.log('statusCode', res.statusCode);
|
console.log('statusCode', res.statusCode);
|
||||||
|
@ -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 { reduceOpenWeather } = require('./libs/reducers');
|
const { reduceOpenWeather } = require('./libs/reducers');
|
||||||
const { distance } = require('./libs/utils');
|
const { distance, hourFloor } = require('./libs/utils');
|
||||||
const TimeFormat = require('hh-mm-ss');
|
const TimeFormat = require('hh-mm-ss');
|
||||||
|
|
||||||
const weatherItem = Backbone.Model.extend({
|
const weatherItem = Backbone.Model.extend({
|
||||||
@ -102,7 +102,8 @@ const WeatherModel = Backbone.Model.extend({
|
|||||||
'url': `${window.loc}/weather`,
|
'url': `${window.loc}/weather`,
|
||||||
'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);
|
||||||
|
@ -48,6 +48,12 @@ function toHour(extra = 0) {
|
|||||||
return (3600000 - (now.getTime() % 3600000)) + extra;
|
return (3600000 - (now.getTime() % 3600000)) + extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hourFloor() {
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
return (~~(now.getTime() / 3600000) * 3600000);
|
||||||
|
}
|
||||||
|
|
||||||
function distance(lat1, lon1, lat2, lon2) {
|
function distance(lat1, lon1, lat2, lon2) {
|
||||||
const p = 0.017453292519943295; // Math.PI / 180
|
const p = 0.017453292519943295; // Math.PI / 180
|
||||||
const c = Math.cos;
|
const c = Math.cos;
|
||||||
@ -65,5 +71,5 @@ function splitURL(url) {
|
|||||||
const maybePluralize = (count, noun, suffix = 's') =>
|
const maybePluralize = (count, noun, suffix = 's') =>
|
||||||
`${count} ${noun}${count !== 1 ? suffix : ''}`;
|
`${count} ${noun}${count !== 1 ? suffix : ''}`;
|
||||||
|
|
||||||
module.exports = { partOfDay, toHour, distance, maybePluralize };
|
module.exports = { partOfDay, toHour, hourFloor, distance, maybePluralize };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user