views:

38

answers:

1

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 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!

A: 

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.

Maurice Perry
okay, I had the first and have now added the other two, but it's not working still. In fact, I've now noticed that a hard refresh isn't always giving me the correct image. Everything says it's looking in the right place... I just don't get it. Could JCrop be storing the image somewhere as a temp file?
Aninemity
Javascript doesn't allow local file manipulation
Maurice Perry
Sorry, can you explain please? I don't understand. I believe jcrop is actually using PHP to manipulate the image, but somehow once it's manipulated if I try and load the image again without refreshing the page ($.post() for example), it displays the original uncropped image instead of the new version of the image. My assumption is that there's some kind of caching going on, but after implementing the cache control headers, I'm still not having any joy, so I'm at a loss...
Aninemity
Well Jcrop is a javascript library, on the server side, you can have PHP, .net, java, or anything else. I believe that the issue you are describing is not specific to Jcrop. Perhaps if you could post some of your code, we could help you better.
Maurice Perry