Skip to content

Instantly share code, notes, and snippets.

@zllovesuki
Last active August 29, 2015 14:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zllovesuki/3f5d001868904eb5cb4c to your computer and use it in GitHub Desktop.
Save zllovesuki/3f5d001868904eb5cb4c to your computer and use it in GitHub Desktop.
Cache Request
<?php
$website = 'http://yourwebsite.com'; //no trailing slash
$key = 'kokenwtf';
/*
*
* RUNNING ON A MACHINE THAT HAS UNLIMITED EXECUTION TIME IS HIGHLY ENCOURAGED
*
* If you have firewall installed on your webserver, whitelist your own IP or disable it
* In case your firewall blacklists you.
*
*/
$urls = file_get_contents($website.'/cache.url.php?key='.$key);
$requests = json_decode($urls, true);
if ($requests === NULL) die;
foreach($requests as $i) {
$ch = curl_init($website.$i);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_exec($ch);
curl_close($ch);
}
@digidan
Copy link

digidan commented Aug 4, 2014

How can I execute this on my mac? Sorry for the noob question but just trying to get this going.

@bb-bragon
Copy link

Hi,

Thx very much for this script (+ cache.url.php). This saved me a lot of time since i'm hosting koken on a small synology NAS: it takes ages to compute all images.
But thanks to your script, once all images are in cache, browsing speed is very good.

BTW, if some want to "monitor" the caching process, you can run those to shell cmd:
cd you_koken_home/storage
count total number of original images
find cache -name "*.jpg" | grep -v 1600 | wc -l
(eg: result is 1147)

count number of cache images grouping by "types"
for filter in```find cache -name "*.jpg" | cut -d',' -f2 | cut -d'.' -f1 | sort -u```; do
echo ${filter} $(find cache -name "*,${filter}.*.jpg" | wc -l)
done

(eg: result is
huge 325
large 325
medium 326
medium_large 1042
small 326
tiny 326
xlarge 325
)

=> 326 pics processed out of 1147.

@drazin
Copy link

drazin commented Jun 5, 2015

what is the key referenced here? i generated an api token but that doesnt seem to be it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment