pre-cache script

benklop Member
edited January 19 in Plugins

hey guys, I just wanted to let you know i've created a zenphoto pre-cache script that will iterate across all gallery images and discover what cached thumbnails and whatnot are missing, and generate them. it is suitable to run in cron once an initial run has been completed. if you want to take a look. so far it seems to work pretty well.


  • I created this since i've got some very large images, and a very slow server, and many of the caches take a few seconds to generate, making album pages horrible to wait for.

  • acrylian Administrator
    edited January 19

    Thanks, contributions like this are always welcome. I will add it to the extensions section soon.

    Are you aware that there is already a pre-cache facility provided by the included cacheManager plugin via a utility button? However, to work properly themes and plugins need to register any image size they use. (Edit: I see your script can be used as a cron job which is indeed different).

    There is also an older python pre-cache script (I never used as my server does not have Python):

  • benklop Member
    edited January 19

    I loosely based this on the python script you mentioned, though by the time i was done just about all of it was replaced. I did know about cacheManager, and in fact used it as a reference when figuring out how to extract information from the database to make this script work.

    At first I made this because CacheManager works through the browser, and it will try to render more than one image at once which totally overwhelms my sad little server. Running it via cron to automatically keep things pre-cached is really my ultimate goal at this point, though.

    This script also has the same limitations that the themes (and plugins too i'd imagine) need to register their image sizes.

    I haven't tried to detect enabled plugins, though you can give the script a --themes flag with a list of additional theme (and i'd assume plugin) names to enable.

    how are enabled plugins stored in the database? If I can get that info, I could pretty easily have this automatically cache needed image sizes from plugins too.

  • acrylian Administrator

    All right and a cron doing this "in the background" is of course more efficient.

    The enabled status of a plugin is stored in the options table named zp_plugin_<name of the plugin> with 0|1 as the value.

Sign In or Register to comment.