Back
imageCacheSecs
Graphic Images
imageCacheSecs
Cache blobs stored in database in the imageTmpDir directory for imageCacheSecs
Default:
Set to a positive number of seconds to cache images. The images are cached in the LENS_IMG_TEMP_DIR directory (PHP constant), or if that is not defined, in the $lens->imageTmpDir directory (phpLens property).

Requires the primary key to be defined with the keyCol property, because we generate temporary file names using the following algorithm:

$file = $lens->imageTmpDir.'/lens_'.$lens->id.'_'.
  md5($lens->id.$lens->keyTable.$key).'.gif';

Note that you will have to delete expired cache files yourself using cron or at.exe. PhpLens does not delete expired files. Also all files are saved with the gif extension, even if they are jpeg or png. All common web browsers ignore the file extension and auto-detect the file type correctly.

Caching
The following properties are used together to enable image caching:

imageCacheSecs: Number of seconds to cache image
imageTmpDirURL: The URL to use from the web browser to read the directory

and you have to modify the following constant in the file phplens/config/phplens.img.config.inc.php

LENS_IMAGETMPDIR: the path to where the images are cached

So suppose the web server root directory is /htdocs, and the images are in /htdocs/img, we set

$lens->imageTmpDirURL = '/img';
$lens->imageCacheSecs = 3600 * 24 * 30; // 30 days

And in phplens.img.config.inc.php

define('LENS_IMAGETMPDIR','/htdocs/img');

Whenever we upload a new image to the server, the cached image file is also deleted automatically.

Note: when cached images are generated, a .gif suffix is added to the filename even if the file uses some other format. This is to ensure that the images are cached by proxy servers.

Compatibility Note

For phpLens 2.8 and earlier, we do not use the phplens.img.config.inc.php file to store the location of the image directory. Instead you have to set the property

imageTmpDir: The location of the image temporary directory on the server

Then you have to modify the source code of phplens-img.php file, changing the hard-coded '/tmp' string with the correct path.

Syntax
$lens->imageCacheSecs = 600; # cache 10 minutes

 Basic:Yes  Advanced/Enterprise:Yes  DynamicEdit:Yes   [Version 2.3.1]