Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ltrain's avatar

Resource (JavaScript, CSS) updates on SPA's with long Session

So my question is 2 parts - one is what would be an average session length for most large application sites? I'm thinking anyway from 1 week to 1 month, but wanted to get some opinions.

More interestingly, let's assume the session is 30 days and you have a single page application that a user leaves open on their browser. They come back to it and since they last used the site let's also say there have been some new code pushes to production, particularly to the minified javascript file that contains vital updates as well as changes to the frontend API, rendering the old version of the javascript file which the user still has unusable for certain parts of the application. The question is - how could the javascript be updated without the user refreshing the page?

One option is to store the current version of the javascript file and poll the database for it, and if it's different force refresh the page for the user, but I feel like their might be a more elegant solution out there and wondering if anyone has come across this issue with Laravel/your choice of SPA Frontend framework here and implemented a solution

0 likes
1 reply
xingfucoder's avatar

Hi @ltrain, did you try to use jQuery Ajax methods with some configuration token created from Laravel? If you want to refresh partially a SPA, I think that you could act with Ajax and cache with Laravel some part of your response.

Please or to participate in this conversation.