PHP Thumb » Help & Bugs » Help

[closed]

How does caching work?

(2 posts)
  1. robbrandt
    Member

    It seems that when I update an original file (larger, same location and name) phpthumb continues to display the original file. I have refreshed my browser, even done "view image" to isolate it from the page and refreshed (which usually works in Firefox) but it's still the original. Only when I delete the folders inside of phpThumb/cache/ do the new versions show up.

    The configuration options seem to suggest that they should be re-caching if the original has changed. The cache settings for phpThumb.config.php are:

    // * Cache directory configuration (choose only one of these - leave the other lines commented-out):
    // Note: this directory must be writable (usually chmod 777 is neccesary) for caching to work.
    // If the directory is not writable no error will be generated but caching will be disabled.
    $PHPTHUMB_CONFIG['cache_directory'] = dirname(__FILE__).'/cache/'; // set the cache directory relative to the phpThumb() installation
    //$PHPTHUMB_CONFIG['cache_directory'] = $PHPTHUMB_CONFIG['document_root'].'/phpthumb/cache/'; // set the cache directory to an absolute directory for all source images
    //$PHPTHUMB_CONFIG['cache_directory'] = './cache/'; // set the cache directory relative to the source image - must start with '.' (will not work to cache URL- or database-sourced images, please use an absolute directory name)
    //$PHPTHUMB_CONFIG['cache_directory'] = null; // disable thumbnail caching (not recommended)
    //if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
    // $PHPTHUMB_CONFIG['cache_directory'] = dirname(__FILE__).'/cache/'; // set the cache directory to an absolute directory for all source images
    //} else {
    // $PHPTHUMB_CONFIG['cache_directory'] = '/tmp/persistent/phpthumb/cache/';
    //}

    $PHPTHUMB_CONFIG['cache_disable_warning'] = true; // If [cache_directory] is non-existant or not writable, and [cache_disable_warning] is false, an error image will be generated warning to either set the cache directory or disable the warning (to avoid people not knowing about the cache)

    $PHPTHUMB_CONFIG['cache_directory_depth'] = 4; // If this larger than zero, cache structure will be broken into a broad directory structure based on cache filename. For example "cache_src012345..." will be stored in "/0/01/012/0123/cache_src012345..." when (cache_directory_depth = 4)

    // * Cache culling: phpThumb can automatically limit the contents of the cache directory
    // based on last-access date and/or number of files and/or total filesize.

    //$PHPTHUMB_CONFIG['cache_maxage'] = null; // never delete cached thumbnails based on last-access time
    $PHPTHUMB_CONFIG['cache_maxage'] = 86400 * 30; // delete cached thumbnails that haven't been accessed in more than [30 days] (value is maximum time since last access in seconds to avoid deletion)

    //$PHPTHUMB_CONFIG['cache_maxsize'] = null; // never delete cached thumbnails based on byte size of cache directory
    $PHPTHUMB_CONFIG['cache_maxsize'] = 10 * 1024 * 1024; // delete least-recently-accessed cached thumbnails when more than [10MB] of cached files are present (value is maximum bytesize of all cached files)

    //$PHPTHUMB_CONFIG['cache_maxfiles'] = null; // never delete cached thumbnails based on number of cached files
    $PHPTHUMB_CONFIG['cache_maxfiles'] = 200; // delete least-recently-accessed cached thumbnails when more than [200] cached files are present (value is maximum number of cached files to keep)

    // * Source image cache configuration
    $PHPTHUMB_CONFIG['cache_source_enabled'] = false; // if true, source images obtained via HTTP are cached to $PHPTHUMB_CONFIG['cache_source_directory']
    $PHPTHUMB_CONFIG['cache_source_directory'] = dirname(__FILE__).'/cache/source/'; // set the cache directory for unprocessed source images

    // * cache source modification date configuration
    $PHPTHUMB_CONFIG['cache_source_filemtime_ignore_local'] = false; // if true, local source images will not be checked for modification date and cached image will be used if available, even if source image is changed or removed
    $PHPTHUMB_CONFIG['cache_source_filemtime_ignore_remote'] = true; // if true, remote source images will not be checked for modification date and cached image will be used if available, even if source image is changed or removed. WARNING: cached performance MUCH slower if this is set to false.

    // * Simplified cache filename configuration
    // Instead of creating unique cache filenames for all parameter combinations, create "simple" cache files (eg: "pic_thumb.jpg")
    // If cache_default_only_suffix is non-empty, GETstring parameters (except 'src') are ignored and only $PHPTHUMB_DEFAULTS
    // parameters (set at the bottom of phpThumb.config.php) are used for processing.
    // The '*' character MUST be used to represent the source image name
    $PHPTHUMB_CONFIG['cache_default_only_suffix'] = ''; // cached in normal phpThumb manner
    //$PHPTHUMB_CONFIG['cache_default_only_suffix'] = '*_thumb'; // cache 'pic.jpg' becomes 'pic_thumb.jpg' (or 'pic_thumb.png' if PNG output is selected, etc)
    //$PHPTHUMB_CONFIG['cache_default_only_suffix'] = 'small-*'; // cache 'pic.jpg' becomes 'small-pic.jpg' (or 'small-pic.png' if PNG output is selected, etc)

    $PHPTHUMB_CONFIG['cache_prefix'] = 'phpThumb_cache_'.str_replace('www.', '', @$_SERVER['SERVER_NAME']);
    //$PHPTHUMB_CONFIG['cache_prefix'] = 'phpThumb_cache'; // allow phpThumb to share 1 set of cached files even if accessed under different servername/domains on same server

    $PHPTHUMB_CONFIG['cache_force_passthru'] = true; // if true, cached image data will always be passed to browser; if false, HTTP redirect will be used instead

    Posted 11 months ago #
  2. Wrong PHP Thumb library my friend :)

    Posted 11 months ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.