首页 > 解决方案 > 如何阻止 Windows Server 2019 上的 iisnode 缓存我的 javascript 文件?

问题描述

我有一个在 iisnode 上运行的 node.js 应用程序,该应用程序在 Windows Server 2019 上运行的 IIS 10 上运行。

在其中一层,似乎有一些 javascript 文件的缓存。例如,在我的 app.js 文件中,我有这个:

fs.appendfilesync('log.txt', 'CORS set up.\n');

...这给了我错误:

appendfilesync is not a function.

我意识到我有一个错字:它应该是驼色的。所以我把它改成:

fs.appendFileSync('log.txt', 'CORS set up.\n');

但它一直给我同样的错误,甚至在文件中指定完全相同的行和列。

我知道缓存正在服务器上发生,因为错误已记录到 iisnode 的日志中,并且因为我将其放置一天,第二天再试一次,错误不再发生。

当我试图修复服务器上的东西并且我无法测试我的修复时,这非常令人沮丧,因为它顽固地不会更新缓存。

如何强制 iisnode、IIS 或 Windows Server 2019(无论哪个正在执行缓存,如果不超过一个)清除缓存或不缓存?

谢谢你。

标签: cachingiis-10iisnodewindows-server-2019

解决方案


Please make sure you assigned the iis_iusrs and iusr full control permission to the log.txt file.

To disable caching in iis you could follow the below steps:

1)using output caching:

  • Select your site in iis.

  • Double click on output caching feature from the middle pane.

enter image description here

  • Click edit feature setting from the action pane.

  • Uncheck Enable cache and Enable kernel cache.

enter image description here

2)clientCache:

  • Open Internet Information Services (IIS) Manager select your site.

  • In the Home pane, double-click HTTP Response Headers.

enter image description here

  • In the Set Common HTTP Response Headers dialog box, check the box to expire Web content, select the option to expire after a specific interval or at a specific time, and then click OK.

enter image description here


推荐阅读