-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Images loaded twice #26
Comments
Hey Matt, is this something you're only seeing in your rails logs, or do you also see two get requests in the chrome/firefox/safari inspectors too? |
Hi Ted, Thanks for your response. I'm seeing it twice in my rails logs and in the I've been playing around with it, and noticed that the image doesn't update -Matt On Tue, Mar 26, 2013 at 4:22 PM, Ted Han [email protected] wrote:
Matthew Jones NEW! We've moved! Our freshly designed office is at 1400 I Street NW Suite |
This seems to only occur in Chrome. In lib/page.js#loadImage, the line
sets the src on the img tag and causes the browser to make a request to load the image. The preloader load event handler then calls drawImage, which has
In Chrome this causes another request to be sent. A second request was not sent in Firefox or IE. For most people with static images, the web server probably handles this second request with a 304 response. I am generating images dynamically, so I added code to explicitly handle this. |
@brentroady: I'm dynamically generating the images as well. Can you post a sample of your code for how you handled the double request? |
My server code is in Asp.Net MVC instead of Rails, but it can probably be translated pretty easily.
Comparing the If-Modified-Since header in the request to the current datetime and returning a 304 if older than a certain elapsed time. Then setting the Last-Modified response header for when generating the image. Hope this helps! |
I'm running an embedded docViewer that pulls images from Rails. I put a debug output statement in the image-return controller action. On first load, it reports just one request for each of the first 3 pages. Each page loaded after that generates 2 requests and gets 2 full responses from rails. One request is coming from DV/lib/page.js#drawImage.js, but I don't know where the other comes from. The page doesn't load until the second request completes.
Is this behavior intended? Is there a way to limit it to a single request?
The text was updated successfully, but these errors were encountered: