0

I'm using pug template engine. I want to cache the pug templates using a database (postgreSQL). The pug templates will have other pug templates included, hence on fetching the parent pug from the cache, included pug files should also be returned. And I'm looking for an incremental cache so that the application does not fetch a stale version of the template while assembling the content.

Can some please advise a suitable implementation?

Mohit Kanwar
  • 2,962
  • 7
  • 39
  • 59
jindal
  • 1
  • Do you realize that pug compiles the templates into JavaScript functions and serves them from memory? – Graham Oct 16 '18 at 13:13
  • To be clear, a caching system such as what you describe would be ineffective with Pug, and counter-productive. – Graham Oct 16 '18 at 13:25
  • @Graham - Thank you for your response! Does that mean if I have to use pug templates, then I must place them within my node project? If that's so, it would make my node package very heavy. – jindal Oct 17 '18 at 05:14
  • Yes, you load them into your node server and they are very lightweight. – Graham Oct 17 '18 at 06:12
  • The bottom line is this - if you don't think that pug is for you then find another project before making it do things it wasn't designed to do (like render out of an rdbms instead of a node server). You'll just cause yourself grief if you do that, and you should find a server-side toolkit that does things the way you want. – Graham Oct 17 '18 at 06:18

0 Answers0