ivmartel / dwv-jqui

Medical image viewer based on DWV (DICOM Web Viewer) and jQuery UI.
https://ivmartel.github.io/dwv-jqui/
GNU General Public License v3.0
19 stars 19 forks source link

JSON file being stored in the cache memory #9

Closed anoob09 closed 6 years ago

anoob09 commented 6 years ago

For some reason the JSON file that I'm using to generate annotations on the DICOM image is being stored in the cache memory of the browser. If I'm making any changes in the JSON file it is not reflected immediately. I have to clear the cache and load the JSON file again to see the changes. How can I resolve this?

ivmartel commented 6 years ago

Are you using the Download state button or some mechanism of your own to save the state? If so, could you share the code?

anoob09 commented 6 years ago

_I am using download state button. Here, I passed the JSON as string to add_annotation_script.php_ this.onStateSave=function(){

var e=new H.State;

var new_json = e.toJSON(o);

var myJSON = JSON.stringify(new_json);

jQuery.post("add_annotation_script.php", {myJSON:myJSON} );

},

_This is the code for add_annotation_script.php. Here I am storing the state.json file in the server._

<?php if (!file_exists("anno/".$rad_id)) { mkdir("anno/".$rad_id,0777,false);}

$path = "C:/wamp64/www/MIC/anno/".$rad_id."/".$image.$case_id.".json";

$f = fopen($path, "w+");

fwrite($f, json_decode($myJSON));

fclose($f);

chmod($path, 0777);

$save_path = "http://localhost/MIC/anno/".$rad_id."/".$image.$case_id.".json"; $sql_res= mysqli_query($dbcon, "select * fromannotationswherecase_id= ".$case_id." andrad_id= ".$view_id." andimage= '".$image."'");

if(mysqli_num_rows($sql_res)==0) {

$sql_anno = "insert into annotations(case_id,rad_id,image,path,submit_id) VALUES('".$case_id."','".$view_id."','".$image."','".$save_path."','".$rad_id."')";

mysqli_query($dbcon, $sql_anno) or die(mysqli_error($dbcon)); }

anoob09 commented 6 years ago

I don't think there's problem with code here. I am not understanding why dwv is not reloading the JSON file from the provided on the URL ? Why is it still using the old JSON file?

anoob09 commented 6 years ago

I turned off cache for the file using .htaccess and it worked.