Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser GET request returning old images

I'm trying to use a GET request to retrieve an image from a server. The image is constantly changing, so I want to grab the image a few times every second (with the intent of displaying the images and imitating video eventually). However, there's something going wrong with the GET request. No matter how rapidly I try to GET the image (tried every 1s, 100ms, etc), it only returns a new image every 5 seconds. It's acting like there's a cached image somewhere and it's only updating the cache every 5 seconds, returning old, duplicate images all other times.

I've done the following to try to isolate the problem:

  • Verified that the images on the server side are actually being updated every 100ms or so, meaning the webpage is indeed returning old images for most of its GET requests,
  • Turned off the browser cache both through developer options and by running the webpage in incognito mode. This is Chrome by the way.
  • Turned off keepalive in the Tomcat server by setting maxKeepAliveRequests = 1 (disabled) in the configuration file.

And yet it is still only actually retrieving new images every 5 seconds.

Example Request Headers:
  Cache-Control: no-cache
  Connection: keep-alive     <-- Could this be the problem? 
  Pragma: no-cache

Example Response Headers:
  Cache-Control: no-cache
  Cache-Control: no-store
  Connection: close
  Pragma: no-cache
  Server: Apache-Coyote/1.1

My query (executed after a time delay every time image is loaded):

document.getElementById("videoDisplay").src = filename + "?random="+(new Date()).getTime();
like image 305
exxodus7 Avatar asked Nov 03 '22 22:11

exxodus7


1 Answers

Found this at http://tomcat.apache.org/tomcat-5.5-doc/config/context.html Read this entry there..

cacheTTL

Amount of time in milliseconds between cache entries revalidation. If not specified, the default value is 5000 (5 seconds).

May be this is the source of your problem

like image 105
Binu Pandian Avatar answered Nov 09 '22 05:11

Binu Pandian