Closed Spone closed 7 years ago
This unit test: https://github.com/pug-php/pug/blob/master/tests/features/pugjs.php#L47
is supposed to check that the cached file is not recreated if the last modified timestamp of the file is newer that the source file. Are filemtime('yourpugfile.pug')
and filemtime('yourcachefile.js')
accurate?
They seem to be, when I check them in the PHP interactive shell:
$ php -a
Interactive mode enabled
php > echo filemtime('cache/pug/icon.js') . ' / ' . filemtime('modules/icon/icon.pug');
1496404382 / 1496404357
And if you reload the page icon.pug
is still 357 and icon.js
changed?
After reloading the page I get:
php > echo filemtime('cache/pug/icon.js') . ' / ' . filemtime('modules/icon/icon.pug');
1496404834 / 1496404357
I don't see the option upToDateCheck
being used in PugJsEngine.php, maybe that's the reason?
upToDateCheck
is not the point, the behavior of this option is:
false
: never refresh at all (assume you cached all the templates on deploy)
true
: refresh only if cacheTime < sourceTime
This check is done here when you use pugjs engine: https://github.com/pug-php/pug/blob/master/src/Jade/Engine/PugJsEngine.php#L146
So there are actually two different issues:
pugjs
AND set 'upToDateCheck' => false
, the cache is still refreshed but it shouldn't bepugjs
without the upToDateCheck
option (or with 'upToDateCheck' => true
), the cache is refreshed even if the source file did not changeHi, I reproduce the bug and will work on it.
It seems, pug-cli just touch the cached file but does not edit it. If you try the following:
use Pug\Pug;
require 'vendor/autoload.php';
$pug = new Pug([
'cache' => 'cache',
'pugjs' => true,
]);
echo $pug->render('view.pug')."\n";
view.pug contains p Hello
You will obtain <p>Hello</p>
Then if you replace "Hello" with "Bye" in cache/view.js
and re-run the php file, you will obtain <p>Bye</p>
, then disable the cache option and re-run again, you get <p>Hello</p>
, it's a proof the cache works, but the last modified time on cache/view.js
is not accurate because pug-cli change this timestamp when it run the file.
So the lonely that could be needed would to restore the original timestamp after render.
Hi, please update to 2.6.3, it allow upToDateCheck to work with pugjs and provide reliable modified timestamp for cached files. If you get troubles please re-open this issue.
Hello,
I switched to using
pugjs
mode for rendering, but I'd like to keep using the cache feature. Right now, even with theupToDateCheck
set totrue
, the js files in my cache folder are refreshed every time I reload the page.Here is the config I use:
Is this the expected behavior?