开发者

JCrop caching image

开发者 https://www.devze.com 2023-01-19 16:11 出处:网络
I\'m trying to implement Jcrop with a list of images. At the moment, when you click the link to crop, a lightbox loads an ajax call with the image and all the cropping tools开发者_如何学C and everythi

I'm trying to implement Jcrop with a list of images. At the moment, when you click the link to crop, a lightbox loads an ajax call with the image and all the cropping tools开发者_如何学C and everything is working great. I've tested across several images in the db and all looks good.

however, once I crop the image and the lightbox closes, if I then try to crop the image a second time, it's still showing me the original image, rather than the newly cropped image. Is there something in jCrop that caches the image and if so, can I switch it off so that it pulls the fresh image each time it's called through ajax? (refreshing the page does update the image to the correct one btw, but that defeats some of the other features I have going on this page.)

Thanks in advance!


I suggest changing the URL when the image data from the server changes - otherwise you'll run into caching issues of many times. Cache-control isn't enough - some browsers ignore the directive.

I'm not sure what server-side platform you're running, but here's an easy solution if it is Windows/IIS.


The image is probably kept in the cache of the browser. This can be avoided with Cache-Control headers on the server side:

Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: max-age=0

This will prevent caching in any case though.


I was also facing the same cache problem. I was using colorbox/fancybox croping window after ajax uploading. But there was same image either if I select the other image. But when I crop the image it crops the right image but the image which is showing in crop window that was Old.

I spent lot of time into this and get the solution. You just need to change the image name randomly, this will resolve the EI cache problem and you will always get the new uploaded image.

Regards, Jitu

0

精彩评论

暂无评论...
验证码 换一张
取 消