You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_isResponseDateFresh(cachedResponse){if(!this._maxAgeSeconds){// We aren't expiring by age, so return true, it's freshreturntrue;}// Check if the 'date' header will suffice a quick expiration check.// See https://github.com/GoogleChromeLabs/sw-toolbox/issues/164 for// discussion.constdateHeaderTimestamp=this._getDateHeaderTimestamp(cachedResponse);if(dateHeaderTimestamp===null){// Unable to parse date, so assume it's fresh.returntrue;}// If we have a valid headerTime, then our response is fresh iff the// headerTime plus maxAgeSeconds is greater than the current time.constnow=Date.now();//todo: if local time is later then service time?returndateHeaderTimestamp>=now-(this._maxAgeSeconds*1000);}
question:
//todo: if local time is later then service time?
const now = Date.now();
return dateHeaderTimestamp >= now - (this._maxAgeSeconds * 1000);
The text was updated successfully, but these errors were encountered:
Hi @wxungang. Here is my naive understanding.
If you're referring to time zone by "local time later than service time", both Date header and Date.now() are in UTC. They will return the same number no matter which time zone you're in.
Refer to Headers/Date and Date.now() for details on Date.
If you're not talking about time zone, pls further clarify your problem.
@wxungang have you tested that this is actually what's happening?
Because I don't think the timezone on your server matters as the time workbox is comparing against the time the document was received and as @EvsChen mentioned everything is in UTC.
Feel free to post your configuration (the service worker code that uses maxAgeSeconds) so that I can check what's wrong
packages/workbox-cache-expiration/plugin.mjs
question:
//todo: if local time is later then service time?
The text was updated successfully, but these errors were encountered: