I'm building a website that requires some image preloading, which is handled smoothly with an overlaid splash screen and a progress bar and a spinner.

The thing is, I want the preloader to know if preloading is necessary (the cache has been wiped, or is disabled in the browser), so that it preloads the images whenever needed. My first approach was using cookies, so that the preloader would be shown only the first time, but refreshing without cache after loading the page rendered my first attempt futile. Then I thought about session variables, but I need to be able to set them via javascript (or AJAX) since the preloader is shown via php (to avoid loading it when it's not necessary).

TL;DR: How can I make my website check if the browser is loading from scratch or if it's loading from a cached version?

Here's the link to my website, so you get a clear idea (works better with Chrome and FF).

how would i check if the page is cached, though? As in: if(!cache) preloader()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.