w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How prevent browser from caching XML file served by Apache? (My htaccess file is included)

I discovered the answer but I'm not sure why it's required and how to change this behavior in Apache.

If I unlink (i.e. delete) the XML file first and then recreate it (instead of just writing over it), then both browsers see the fresh version!

//This causes a fresh version
unlink( $xmlFileLocation );

//Now creating it will result in a non-cached version being sent
$f = fopen( $xmlFileLocation, "wb" );
fwrite(, $xmlFileLocation, $xml );
fclose( $xmlFileLocation );

If I do the above without unlink, then it gets changed and the modified date is updated on disk, but Apache continues to serve the old version!! Why?

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.