Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3398304
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:37:59+00:00 2026-05-18T04:37:59+00:00

I am using a JavaScript script that tells me if specific image URLs are

  • 0

I am using a JavaScript script that tells me if specific image URLs are cached in the user’s browser cache. I’m using this because I build an array of non cached images that will be loaded separately, after more important process is done. This script is wrote specifically for Google Chrome so I don’t need a cross-browser solution.

My current function checks the time spent loading the image and if it is less than a few milliseconds (currently 25ms), I assume it is pulled from cache.

The difference between cached and not cached images is easy to spot manually by checking the Resources Panel in Chrome’s Developers Tool. When hovering the loading time, Chrome tells if file was pulled from cache or not by printing a tool-tip looking like this: xx ms Latency, xx ms Download (from cache).

I noticed that on some occasions, the Latency time is quite long (e.g. 64ms for only 2ms downloading time) and makes my detect function useless as the total loading time then exceeds my threshold. Increasing the threshold is not possible as small and not cached images could also be loaded in the same amount of time.

Now that you got my problem, here goes my question:

-Is it possible to check in a 100% accurate way (e.g. like chrome’s resources panel) that file comes from cache ? (I guess if that panel does it, there has to be a way but I couldn’t find it on the Internet)

Or

-Is there a way to separate the two delays (i.e. Latency vs. Download) to be able to check only the true downloading time ? Calculating time spent between starting the load of the image and the onload event returns the total amount of time.


I thank you for reading my question and even if you don’t have a precise solution, thoughts, ideas, are most welcome !

(PS: I am not a native english speaker so please don’t blame me for doing mistakes !)

Gaël

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:38:00+00:00Added an answer on May 18, 2026 at 4:38 am

    Sorry for mistaking your answer.

    I have done some tests and found the following results: The 304 not modified header only appear when the resource is stale and validated by the server via If-None-Match/If-Modified-Since. When the resource is still fresh and does not require validation, the status code returned is 200 Ok.

    However, it seems there is a Age header that indicates resource is being cached.
    So I guess I could switch to PHP and do something like if status code is 304 or Age header exists then resource is cached. But what if there is no Cache-Control: max-age=xx header ? Is there an Age header anyway as soon as the resource is cached and fresh ?

    Will investigate further on Monday and keep it updated here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's assume I browse a specific web page that uses JavaScript to update its
Below is my script that updates my characters position in my database: <script language=javascript
I am trying to link to a file that has the '#' character in
I'm writing my first little AJAX-enabled Joomla component. I'm using mootools. I got a
Friends, I have written the following JavaScript to ascertain which row of an tabular
We are using version 3.0.20229.0 of the asp.net ajaxControlTookKit (before .net 3.5 sp1). I
I'm trying to convert Chinese lunar system to Gregorian using Perl, both for fun
I've wasted at least a half day of my company's time searching the Internet
jQuery based modal dialog boxes are great as long as you do as much
I just spent half an one our to find out what caused the Error-Message

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.