pug-php / pug

Pug template engine for PHP
https://www.phug-lang.com
MIT License
391 stars 42 forks source link

[Feature Request] Add option to cacheDirectory to skip/overwrite #172

Closed MikeDombo closed 7 years ago

MikeDombo commented 7 years ago

Hi, I just switched to version 3 and found that the performance was greatly decreased compared to version 2. I never used caching before, but now with version 3 it seems necessary. The readme says that I can run a command to cache all templates, but that this should only be run once.

It would be great to have an option so that the cacheDirectory function will check and not recompile templates that are not updated. This would be the same as "upToDateCheck" in the render functions. In this way, the very first time it is run it will be quite slow, but every request afterward will be quick and will also keep the cache up to date with the current templates.

kylekatarnls commented 7 years ago

Hi, Sorry to hear you get such trouble.

We have a big plan #168 and talk a lot about it in our slack to improve performance, but our priority will still be the cached version, the next version cache should provide faster cached templates rendering than pug-php 2.

I would far prefer to help to get the cache working than provide feature to work around the cache system.

The best practice is:

So such option for ->cacheDirectory could be interesting to fasten the deployment process. But you certainly not should call ->cacheDirectory with or without such option during a page request rendering of a real user in your production environment.

MikeDombo commented 7 years ago

Thanks for your reply. I'll follow that issue you posted and I will consider adding that code to my deployment process so that it does not have to render the pug at the time that a user requests the page.