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.
Why a __SbCache
is being added to those static files ? Due this issue, static file caching is not working properly.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With