php - AJAX Don't want to cache images -
i have web form takes c++ code, compiles on server, , spits output out. c++ code in question writes out bmp file can viewed on web page. interfaced via ajax. main issue whenever recompile program change image, image in question not change unless refresh page. therefore assume caching problem. here steps:
- person inputs c++ code
- person presses submit
- c++ code sent compile.php
- compile.php compiles program , displays images in directory
if person changes color of image in program , resubmits form, submit successful image not change unless page refreshed. verified when changed output filename , creates new image correct colors, if recompile program same filename, particular image not change unless refresh page.
i tried putting no-cache headers @ top of php files.
<?php header("expires: mon, 26 jul 1990 05:00:00 gmt"); header("last-modified: " . gmdate("d, d m y h:i:s") . " gmt"); header("cache-control: no-store, no-cache, must-revalidate"); header("cache-control: post-check=0, pre-check=0", false); header("pragma: no-cache"); ?>
to solve issue, try disabling caching in javascript library when making ajax request. jquery, set cache
false
.
another solution manually append cache-busting parameter when making request. example, instead of making ajax request compile.php
, make request compile.php?123456
123456
current timestamp. should force browser not use cached copy.
Comments
Post a Comment