Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodej.js : Static file caching not working due unnecessary query parameter

My Node.js code to cache the static files as follows :

app.use(express.static(path.join(__dirname, "public"),
    { maxAge: (process.env.NODE_ENV === "local") ? 0 : 31557600000 }));

The public folder contains all the static files for my server.

The html code (I am using EJS ) which calls the static file is :

<script src="/assets/js/slick.min.js"></script>
<script src="/assets/js/main.js"></script>
<!--for form validation -->
<script src="/assets/js/parsley.min.js"></script>
<script src="/assets/js/moment.min.js"></script>
<script src="/assets/js/wheelzoom.js"></script>
<script src="/assets/js/alertify.js"></script>
<script src="/assets/js/alertify.min.js"></script>
<script type="text/javascript" src="/assets/js/validator.min.js"></script>
<script src="/assets/js/owl.carousel.min.js"></script>
<script src="/assets/js/jquery.bootstrap.wizard.min.js"></script>

But when I visit the page and checked the network tab on chrome, I see that due to query parameter added to the static file get calls, browser is not loading the file from cache, instead it requests the server.

enter image description here

Why a __SbCache is being added to those static files ? Due this issue, static file caching is not working properly.

like image 951
NIKHIL C M Avatar asked Sep 14 '25 11:09

NIKHIL C M


1 Answers

I had the same problem, which is only occurs in chrome.

I found that's because of a chrome extension:Postman Interceptor 0.2.24

When I disable it, the problem disappear.

like image 108
Shindou-L Avatar answered Sep 16 '25 01:09

Shindou-L