11611

disable EJS caching in production

Question:

It seems like whenever my process.NODE_ENV is set to production, EJS templating engine will cache all my .html files. So any modifications in those files will not be displayed, unless server restarts.

app.engine('.html', require('ejs').__express);

Is there a way to disable caching template on express? Thanks!

Answer1:

It seems like <a href="https://github.com/expressjs/express/blob/e5ec966b2f068e935ea1b33374fac133dd06cdc8/lib/application.js#L117" rel="nofollow">this is set explicitly as part of express's built-in code</a>

if (env === 'production') { this.enable('view cache'); }

This gets called by app.init which is called by createApplication which is the function that gets exported and what you probably are calling with app = express(). You can immediately disable the caching on your own:

app = express(); app.disable('view cache');

Recommend

  • Nodejs, expressjs - how to serve delayed response
  • having trouble adding a view as a subview to multiple view - iphone dev
  • .NET Entity Framework Core
  • Delayed expansion and exclamation marks in strings
  • How to do feature selection using linear SVM weights [closed]
  • Visual Studio output window is not displaying messages sent by Debug.Write()
  • SQLSTATE[HY000] [1045] exception while connecting to database using 000webhost
  • using ant ivy in netbeans
  • How to use multi dimensional STL vector in MPI
  • How to implement a callback method within DLL (Delphi / TJVPluginManager + TJvPlugin)
  • How would I make a polygon based on the relative positions of markers in google maps?
  • Gitlab: copy project to other git lab repository
  • Use awk to convert GPS Position to Latitude & Longitude
  • Authorize Attribute Authentication with Postman in Web Api
  • Adding native code to an existing Worklight hybrid app
  • cSPADE data mining in R using arulesSequences - Error while converting to “transactions” format
  • 'float' object cannot be interpreted as an integer
  • view details for exception in vs 2017
  • Haskell program that can handle any arbitrary deterministic finite automaton
  • VBScript InputBox and Help Files
  • Multiple table join MySQL multiple foreign keys
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • how can i get selectedRange.location value?
  • Reload Page with Javascript after Database changes
  • How to resolve this in PHPUnit where it is asking me to set KERNEL_DIR in my phpunit.xml?
  • Swift: UIView.animate works unexpectedly
  • Multiplying polynomials/simplifying like terms
  • How to write seo friendly url's using htaccess?
  • Django, uWSGI & nginx: Process dies for “no reason”
  • using maven pom while creating jar:test-jar some times it says JAR will be empty - no content was ma
  • Android: Unable to detect vertical plane
  • Using redis as an LRU cache for postgres
  • `$http:badreq Bad Request Configuration` - from angular post method, what is wrong here?
  • Debug `Unexpected end of JSON input Error` on content script
  • Apple Mach-O Linker error (“duplicate symbol”)
  • Using Service Component Runtime
  • Angular FormGroup won't update it's value immediately after patchValue or setValue