Skip to content

Commit 1acfe2a

Browse files
committed
fix FPC issue when using ajax
1 parent c7d7842 commit 1acfe2a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

view/frontend/web/js/action/submit-filter.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,18 @@ define(
4747
/** start loader */
4848
loader.startLoader();
4949

50-
/** change browser url */
50+
/** fix load page FPC */
51+
const url = new URL(window.location);
52+
url.href = submitUrl;
53+
if(url.searchParams.get('mpLayer')){
54+
url.searchParams.delete('mpLayer');
55+
window.history.pushState({}, '', url);
56+
}
57+
/** change browser url */
5158
if (typeof window.history.pushState === 'function' && (typeof isChangeUrl === 'undefined')) {
52-
window.history.pushState({url: submitUrl}, '', submitUrl);
59+
window.history.pushState({url: submitUrl}, '', url.href);
5360
}
61+
5462
if (method === 'post') {// For 'add to wishlist' & 'add to compare' event
5563
return storage.post(submitUrl).done(
5664
).fail(
@@ -62,7 +70,7 @@ define(
6270
});
6371
}
6472

65-
return storage.get(submitUrl).done(
73+
return $.get({url:submitUrl,cache:true},{'mpLayer': 1}).done(
6674
function (response) {
6775
if (response.backUrl) {
6876
window.location = response.backUrl;

0 commit comments

Comments
 (0)