dodo Moderator Da Lithuania Membro dal mar 2016 dodo 2 mag 2020 11:10 I have issues with images cache. Uploaded new pictures to the product, but some thumbnails are left from old images. What I did try to solve it: Empty cache from admin panel. Empty cache by deleting cache directory. CTRL + F5 in the browser. What else might I try?
vilaiporn LiteCart Fan Da Thailand Membro dal ago 2017 vilaiporn 2 mag 2020 12:19 Did you already try from another browser/computer?
jsl LiteCart Fan Da Malaysia Membro dal mar 2018 jsl 2 mag 2020 14:26 change all the image name and upload a brand new set. i get this problem too and this is how i solve it
tim Founder Da Sweden Membro dal mag 2013 tim 2 mag 2020 16:31 Make sure there is no server cache mechanism like Cloudflare, Supercache or similar. Can you verify over FTP that the file in the cache folder is the old one?
dodo Moderator Da Lithuania Membro dal mar 2016 dodo 4 mag 2020 15:32 I only managed to work by renaming the product. Then new file names were given for images. Not sure what was the issue.
tim Founder Da Sweden Membro dal mag 2013 tim 6 mag 2020 20:02 I remember patching an issue with clearing specific thumbnails. Maybe this is resolved in 2.2.3? https://github.com/litecart/litecart/blob/8c65c75d5732b5974d83241525fd11f9198e7bdc/public_html/includes/functions/func_image.inc.php#L158-L169
Eliminato Da Sconosciuto 4 lug 2020 12:26 System Cache Enabled = False It still creates cache files. Images in shipping section don't update. Some product images won't update. Why does it use cache even if setting is false? I literally have to delete all folders in cache directory to make this work.
tim Founder Da Sweden Membro dal mag 2013 tim 5 lug 2020 04:43 Thumbnails Cache and System Cache are not the same. Thumbnail cache can not be turned off. Only cleared. See Settings -> Images. Thumbnail generation eats too much ram and cpu on the server. You can also manually delete all subfolders in cache/ to start off fresh.
candypalace Merchant Da United Kingdom Membro dal apr 2023 candypalace 13 nov 2023 05:28 My son who manages my site, came across a similar issue while building an admin app that applies stickers to the main product image and he used Tims suggestion of using the following function : function image_delete_cache($file) { $webpath = preg_replace('#^('. preg_quote(FS_DIR_APP, '#') .')#', '', str_replace('\', '/', $file)); $cachename = sha1($webpath); $files = glob(FS_DIR_APP . 'cache/' . $cachename .'*'); if ($files) foreach ($files as $file) { unlink($file); } } As this function is already declared, All he needed to do was put the following line after the code that saves the Image: //The code in our admin app that saves the processed image $image = current($product->data['images']); $outputImagePath = FS_DIR_STORAGE . 'images/' . $image['filename']; Below is the code you would use to clear the cache. but you probably would be using some other name than $outputImagePath // Delete cached versions of the processed image image_delete_cache($outputImagePath); Hope this helps
candypalace Merchant Da United Kingdom Membro dal apr 2023 candypalace 16 dic 2023 01:44 We found that the above method of using image_delete_cache($outputImagePath); didn't always work so well, so we use the following method that has worked every time so far: <?php header('Expires: Fri, 20 Jan 1984 01:11:11 GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); ?>
candypalace Merchant Da United Kingdom Membro dal apr 2023 candypalace 17 dic 2023 01:28 Although the above solution works in the app my son has made, It doesn't work with the rest of the website for thumbnails. I know we can go to settings / images and delete cache from there but that's not what we want as we are working on only one image we don't want to delete the whole cache of images. I was wondering if there is a solution to just delete the cached thumbnails of the image we are working on.
candypalace Merchant Da United Kingdom Membro dal apr 2023 candypalace 17 dic 2023 01:38 I know we could do things like renaming the edited image but that would also need a database update to reflect the new image name. However this is not an option in the app my son has built because the app is part of his college course and the tutor has set strict guidelines. One of those guidelines being that the app must not perform any updates to the database or permanently alter the original codebase. Although technology such as Vmods are allowed.
tim Founder Da Sweden Membro dal mag 2013 tim 18 dic 2023 05:32 If you have a browser cache problem, try outputting the image url with rlink() for resource URLs. Note FS for filesystem paths and not WS. <img src="<?php echo document::href_rlink(FS_DIR_APP . 'path/to/image.jpg'); ?>"> If you have a problem with server cache, that is resolved by cleaning the thumbnails cache under Admin -> Settings -> Images or run the individual command image_delete_cache($image_path). If you have a problem with CDN cache, empty the cache at the CDN service and always use rlink() to output image resources. https://wiki.litecart.net/introduction#links