We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40131
    • 40 Posts
    Hi,

    I have found that phpThumbOf v.1.4 on Revo 2.2.6 does not obey its settings (incl. the default one):

    phpthumb_cache_maxfiles = 10000
    phpthumb_cache_maxsize = 100

    Currently I got more than 17000 files and size more that 270 MB. Plugin "phpThumbOfCacheManager" is enabled and working properly. When clearing cache it empties phpThumbOf cache folder.

    On my server I found that if phpThumbOf cache folder reaches 100 000 or more files, this makes a disastrous slowdown on the entire frontend website and page loading.


    Any clues?
      • 35150 ☆ A M B ☆
      • 191 Posts
      I was just looking at the cache cleanup code the other day and wondering if it worked at all or if I was missing something. In core/model/phpthumb/phpthumb.class.php starting on line 658 there's this:
      $AllFilesInCacheDirectory = phpthumb_functions::GetAllFilesInSubfolders($this->config_cache_directory);
      			foreach ($AllFilesInCacheDirectory as $fullfilename) {
      				if (preg_match('/^phpThumb\_cache\_/i', basename($fullfilename)) && file_exists($fullfilename)) { ...


      Because phpthumbof's cache isn't named phpThumb_cache, I think phpThumb's CleanUpCacheDirectory method doesn't do anything but waste time listing all the files in the cache directory. The cache cleanup gets run every time you call phpthumbof, so with a large number of files in the cache directory this'll definitely start affecting performance.
      Sometime soon I'm going to look into this more and fix it if it's indeed not working.

      In the meantime there are a few easy–if hacky–fixes:

      • Edit core/components/phpthumbof/model/phpthumbof/phpthumbofclass.php and comment out $this->cleanCache(); on line 348
      • -or- under Systems Settings / core > phpThumb set phpThumb Max Cache Age, Files, and Size to 0
      Both of these turn off cache cleanup. The first one is slightly faster.

      One of the reasons you have so many files in your cache may be because of the way phpthumbof names cache files. If you're using the same image with the same parameters on multiple pages, it'll create separate images for each instance. See this pull request for some more information and a fix: https://github.com/splittingred/phpThumbOf/pull/49
        Extras :: pThumb • Resizer • imageSlim • setPlaceholders
        • 40131
        • 40 Posts
        Quote from: jgrant at Mar 14, 2013, 10:05 AM
        I was just looking at the cache cleanup code the other day and wondering if it worked at all or if I was missing something. In core/model/phpthumb/phpthumb.class.php starting on line 658 there's this:
        $AllFilesInCacheDirectory = phpthumb_functions::GetAllFilesInSubfolders($this->config_cache_directory);
        			foreach ($AllFilesInCacheDirectory as $fullfilename) {
        				if (preg_match('/^phpThumb\_cache\_/i', basename($fullfilename)) && file_exists($fullfilename)) { ...


        Because phpthumbof's cache isn't named phpThumb_cache, I think phpThumb's CleanUpCacheDirectory method doesn't do anything but waste time listing all the files in the cache directory. The cache cleanup gets run every time you call phpthumbof, so with a large number of files in the cache directory this'll definitely start affecting performance.
        Sometime soon I'm going to look into this more and fix it if it's indeed not working.

        In the meantime there are a few easy–if hacky–fixes:

        • Edit core/components/phpthumbof/model/phpthumbof/phpthumbofclass.php and comment out $this->cleanCache(); on line 348
        • -or- under Systems Settings / core > phpThumb set phpThumb Max Cache Age, Files, and Size to 0
        Both of these turn off cache cleanup. The first one is slightly faster.

        One of the reasons you have so many files in your cache may be because of the way phpthumbof names cache files. If you're using the same image with the same parameters on multiple pages, it'll create separate images for each instance. See this pull request for some more information and a fix: https://github.com/splittingred/phpThumbOf/pull/49


        Thanks a million!! Your solution made a performance boots I have never seen. Especially the fix for duplicate thumbnails with same path.

        But I noticed something new - it seems that the above somehow ruined the thumbnails in the manager. Not all thumbs load. Some pics are just blank, it looks random.

        I suspect It might be related to CacheMaster, because I have 2 similar sites, one with CacheMaster (thumbs not loading in the manager), the other w/o CacheMaster, and thumbs are ok..., hm [ed. note: nickyz last edited this post 13 years, 6 months ago.]
          • 35150 ☆ A M B ☆
          • 191 Posts
          Quote from: nickyz at Mar 14, 2013, 02:10 PM
          I suspect It might be related to CacheMaster, because I have 2 similar sites, one with CacheMaster (thumbs not loading in the manager), the other w/o CacheMaster, and thumbs are ok..., hm

          That's an interesting observation. I'm running those phpthumbof changes on a few different sites and haven't noticed any problems with thumbnails in the manager, but none of those sites are using CacheMaster..
          You might try manually clearing out core/cache/ to make sure some old thumbnail filenames aren't cached somewhere.
          If that fixes it or if you find out any more details on what's causing the problem please let me know! [ed. note: jgrant last edited this post 13 years, 6 months ago.]
            Extras :: pThumb • Resizer • imageSlim • setPlaceholders
            • 40131
            • 40 Posts
            The problem appeared to be eAcelerator, and nothing related to CacheMaster. I switched back to XCache and everything works fine now.