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:

  1. person inputs c++ code
  2. person presses submit
  3. c++ code sent compile.php
  4. 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

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -