When setting the storage location there is a lot of data written, cache folder included.
Pretty sure there is a way to clear the cache folder upon exit, but have not used that function. Rather not if possible…
What I am looking for is allow the user to clear the cache (maybe using a button). Sometimes our software pulls in updates from the net and clearing the cache folder ensure the updates are shown on next restart of the software.
Could you please provide me example code to use with a button if possible?
When using upload functions (images for example) the past images are cached and will show even new image has been uploaded. Only way to get new image to show is exit and restart the software.
This is show stopper for me and have had to use other methods to build my software.
Is there any way to force reload of a page and clear the page cache? Even disabling local cache has no effect.
I do not want to choose the option to NOT create a storage folder and even if did, would fix the problem. User would still have to exit the software.
The correct way for an image not to be cached is to use a key for image, for example:
Example :
<?php
$key = rand(0,35);
$imagekey = “&key=”.$key;
echo “< img src=‘mydir/img/img.jpg$imagekey’ >”
?>
I do not know if that’s your question … when I work with image, I like using the key to remove the cache.
Thank you @wayos. As always your input is invaluable.
Having issues with images and some .js files. Using your input for image ideas, have found way that works for me:
myimage.jpg?nocache=<?php echo time(); ?>
This works every time without fail (at least in my tests). In my case uploading an image that always remains the same name so this ensures new name when page is reloaded:)
Got to find a way to clear the .js files when needed, but that is minor at this time.
If you are going to use ajax (jquery) just use the cache:
1 ------------------------------------------
$.ajaxSetup({
cache: false;
});
2 -------------------------------------------- OR
jQuery.cachedScript = function( url, options ) {
// Allow user to set any option except for dataType, cache, and url
options = $.extend( options || {}, {
dataType: "script",
cache: false,
url: url
});
// Use $.ajax() since it is more flexible than $.getScript
// Return the jqXHR object so we can chain callbacks
return jQuery.ajax( options );
};
// Usage
$.cachedScript( "ajax/test.js" ).done(function( script, textStatus ) {
console.log( textStatus );
});