Skip to content

Commit 5983e17

Browse files
committed
MC-36096: [Cloud] Local cache storage is not retained for the expected period.
1 parent 2aaa969 commit 5983e17

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ define([
3030
url.setBaseUrl(window.BASE_URL);
3131
options.sectionLoadUrl = url.build('customer/section/load');
3232

33-
storage = $.initNamespaceStorage('mage-cache-storage').localStorage;
34-
storageInvalidation = $.initNamespaceStorage('mage-cache-storage-section-invalidation').localStorage;
35-
3633
/**
3734
* @param {Object} invalidateOptions
3835
*/
@@ -214,11 +211,18 @@ define([
214211
this.reload(sectionConfig.getSectionNames(), true);
215212
$.cookieStorage.set('section_data_clean', '');
216213
}
214+
},
217215

216+
/**
217+
* Storage init
218+
*/
219+
initStorage: function () {
218220
$.cookieStorage.setConf({
219221
path: '/',
220222
expires: new Date(Date.now() + parseInt(options.cookieLifeTime, 10) * 1000)
221223
});
224+
storage = $.initNamespaceStorage('mage-cache-storage').localStorage;
225+
storageInvalidation = $.initNamespaceStorage('mage-cache-storage-section-invalidation').localStorage;
222226
},
223227

224228
/**
@@ -356,6 +360,7 @@ define([
356360
*/
357361
'Magento_Customer/js/customer-data': function (settings) {
358362
options = settings;
363+
customerData.initStorage();
359364
invalidateCacheBySessionTimeOut(settings);
360365
invalidateCacheByCloseCookieSession();
361366
customerData.init();

0 commit comments

Comments
 (0)