I''m running a Rails application with WEBrick server. We are displaying an Image from the server to the Client (Browser). First time on the browser everything looks fine, upon clicking the link, it contacts the server and displays in IE brwoser the image that was stored on the server. But in case if the image gets changed on the server(File Name being the same), then even though i click the refresh button on IE, the Browser still Loads the old image !!!. Has any body seen the above problem. I think IE is caching the IMAGE file and it does not clear the chache even though i click the link or refresh the whole page to get the new image from the server? Any ideas? kindly pl let me know.. I''m running on Webrick Server. Thank You, Dinesh -- Posted via http://www.ruby-forum.com/.
On Jun 16, 2006, at 9:19 PM, Dinesh Umanath wrote:> But in case if the image gets changed on the server(File Name being the > same), then even though i click the refresh button on IE, the Browser > still Loads the old image !!!. Has any body seen the above problem. I >How are you sending the image? I use send_data, and switch off the cacheing completely (because my image is generated again for every request) # Explicitly switch off image cacheing expires_now send_data(session[:image], :type=>"image/png", :disposition=>"inline") This isn''t a good solution for images that only change *sometimes*, but it might help you to find a better solution. -jim
Dinesh Umanath wrote:> Any ideas? kindly pl let me know..> Thank You, > DineshYou might want to try setting the IE cache setting within IE''s Options to ''Every visit to the page'' - I know that in the past having it set to ''Automatic'' would cause problems seeing updates even when I was specifically refreshing the page hope it helps, Chris -- Posted via http://www.ruby-forum.com/.
Hi Jim, Thanks for your reply. In the "show.rhtml" page i''m having this code which uses AJAX to get the image Asynchronously . After that the image is rendered to the client.. **************************************************************************** show.rhtml ----------- <%= link_to_remote(:update => ''updatediv'', :url => { :action => :get_images }) %></td> <div id="updatediv"></div> **************************************************************************** In the "contoller" i''m having this action def get_images @responseImage="/images/myImages/Image1.png" end **************************************************************************** In the "view" i''m having this code.. <%= @responseImage %> **************************************************************************** So can send_date or send_file can solve the above problem ?? Thank You, Dinesh Jim Cheetham wrote:> On Jun 16, 2006, at 9:19 PM, Dinesh Umanath wrote: >> But in case if the image gets changed on the server(File Name being the >> same), then even though i click the refresh button on IE, the Browser >> still Loads the old image !!!. Has any body seen the above problem. I >> > How are you sending the image? I use send_data, and switch off the > cacheing completely (because my image is generated again for every > request) > > # Explicitly switch off image cacheing > expires_now > send_data(session[:image], :type=>"image/png", > :disposition=>"inline") > > This isn''t a good solution for images that only change *sometimes*, but > it might help you to find a better solution. > > -jim-- Posted via http://www.ruby-forum.com/.
Hi Chris, Thanks for the reply. I''m already having the Setting on my browser as ''Every visit to the page''. But still no luck!! Any other ways ? Dinesh Chris wrote:> Dinesh Umanath wrote: > >> Any ideas? kindly pl let me know.. > >> Thank You, >> Dinesh > > You might want to try setting the IE cache setting within IE''s Options > to ''Every visit to the page'' - I know that in the past having it set to > ''Automatic'' would cause problems seeing updates even when I was > specifically refreshing the page > > hope it helps, > Chris-- Posted via http://www.ruby-forum.com/.
On Jun 16, 2006, at 10:09 PM, Dinesh Umanath wrote:> So can send_date or send_file can solve the above problem ??Erm, no ... but expires_now may still help, in controller method get_images.
Dinesh Umanath
2006-Jun-16 11:51 UTC
[Rails] Re: Re: Issue with caching of .PNG files in IE..
Jim, In your case you are also displaying the image finally in the browser itself rt may be in a''div'' element using ''send_data''? with "inline" otion, then it should work for me also rt? Dinesh Jim Cheetham wrote:> On Jun 16, 2006, at 10:09 PM, Dinesh Umanath wrote: >> So can send_date or send_file can solve the above problem ?? > > Erm, no ... but expires_now may still help, in controller method > get_images.-- Posted via http://www.ruby-forum.com/.
Jim Cheetham
2006-Jun-16 21:21 UTC
[Rails] Re: Re: Issue with caching of .PNG files in IE..
On Jun 16, 2006, at 11:51 PM, Dinesh Umanath wrote:> In your case you are also displaying the image finally in the browser > itself rt may be in a''div'' element using ''send_data''? with "inline" > otion, then it should work for me also rt?Yes -- my controller''s view generates an <img> tag which is a reference to another controller method, which uses send_data to return the image inline. You could do that if you wanted to :-) However, just using ''expires_now'' for every image is a bit of a large hammer; it depends on how often your images really change, and how much caching you want the clients to be able to do. <img src="<%= url_for({:action=>''reflectpng'',:id=>@image.id}) %>" /> and it''s method ''reflectpng'' that used send_data. -jim
2006/6/16, Dinesh Umanath <u_dinesh@yahoo.com>:> I''m running a Rails application with WEBrick server. We are displaying > an Image from the server to the Client (Browser). First time on the > browser everything looks fine, upon clicking the link, it contacts the > server and displays in IE brwoser the image that was stored on the > server. > > But in case if the image gets changed on the server(File Name being the > same), then even though i click the refresh button on IE, the Browser > still Loads the old image !!!. Has any body seen the above problem. I > think IE is caching the IMAGE file and it does not clear the chache even > though i click the link or refresh the whole page to get the new image > from the server? > > Any ideas? kindly pl let me know.. > > I''m running on Webrick Server.image_tag or image_path can do this. or: <img src="<%= "web_path.png?#{File.mtime(full_path.png).to_i}" %>" />
Hi Jim Thanks for your response. I tried with send_data using the <img> tag and it works fine !!!. But my problem is i want to do it through AJAX, and i''m not sure how to do it with AJAX. ie. when we call the link_to_remote(...), it emits the output using the :update ie. we can define an empty <div id="updatediv"></div> like this and we can ask :update=>''updatediv'', which will emit the output of link_to_remote into the div element which is fine. But in our case, in the contoller i''m using send_file like this send_file(''public/images/myImage.png'',type=>"image/png",:disposition=>"inline"), so the AJAX when it receives this file it will update in the ''updatediv'' element. But i want to use <img> tag here, ie get the updates from AJAX and update it using the <img> tag, i still dont know whethere it makes sense or not. ie. bottom line -> AJAX + send_file + <img> tag is what i''m trying to do so that i will..but still no luck and struggling..:) Thanks again for your kind replies.. Dinesh Jim Cheetham wrote:> On Jun 16, 2006, at 11:51 PM, Dinesh Umanath wrote: >> In your case you are also displaying the image finally in the browser >> itself rt may be in a''div'' element using ''send_data''? with "inline" >> otion, then it should work for me also rt? > > Yes -- my controller''s view generates an <img> tag which is a reference > to another controller method, which uses send_data to return the image > inline. You could do that if you wanted to :-) However, just using > ''expires_now'' for every image is a bit of a large hammer; it depends on > how often your images really change, and how much caching you want the > clients to be able to do. > > <img src="<%= url_for({:action=>''reflectpng'',:id=>@image.id}) %>" /> > > and it''s method ''reflectpng'' that used send_data. > > -jim-- Posted via http://www.ruby-forum.com/.
Jim Cheetham
2006-Jun-19 21:23 UTC
[Rails] Re: Re: Re: Issue with caching of .PNG files in IE..
On Mon, Jun 19, 2006 at 09:00:38AM +0200, Guest wrote:> But in our case, in the contoller i''m using send_file like this > send_file(''public/images/myImage.png'',type=>"image/png",:disposition=>"inline"), > so the AJAX when it receives this file it will update in the ''updatediv'' > element. But i want to use <img> tag here, ie get the updates from AJAX > and update it using the <img> tag, i still dont know whethere it makes > sense or not.I had a really ugly solution to this, with the original ajax call returning the HTML <img>, and passing in some parameters to the src of the image tag ... but I suspect you would be able to simplify this using RJS these days. RJS gets rid of the :update argument, and gives you a pure Ruby environment where you can update as many different page sections as you like ... But this isn''t really a cacheing question any more, so perhaps starting a new message thread asking about that would be a good idea. -jim