更新一个html文件 [英] Updating a html file

查看:25
本文介绍了更新一个html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在Heroku上托管我的小项目.

I'm hosting my little project on Heroku.

我的问题是,例如,当我写入HTML文件时,它就是代码

My problem is that when I write to an HTML file it's code, for example

fs.writeFile('home.html', <html><body>Hello</body><html>, function (err) {
        if (err) return console.log(err);
});

它已写入文件,一切正常,但没有更新.因此,如果我在更新后进入页面,我会看到旧页面.我已经离线测试过了,效果还不错.

It write to the file and everything is ok but it doesn't update it. So if I would enter the page after the update, I'll see the old one. I've tested it offline and it worked ok.

它不是从缓存中获取页面.我放了

It's not taking the page from the cache. I've put

<meta http-equiv="expires" content="0"> 

在HTML文件中,它没有帮助.

In the HTML file and it didn't help.

推荐答案

Heroku的文件系统是短暂的:

每个dyno都有自己的临时文件系统,其中包含最新部署的代码的新副本.在dyno的生存期内,其运行的进程可以将文件系统用作临时暂存器,但是任何其他dyno的进程都看不到已写入的文件,并且在dyno停止或重新启动时,所有写入的文件都将被丢弃.例如,在由于应用程序部署而更换测功机的任何时候都会发生这种情况,并且在正常测功机管理的一部分中大约每天一次.

Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad, but no files that are written are visible to processes in any other dyno and any files written will be discarded the moment the dyno is stopped or restarted. For example, this occurs any time a dyno is replaced due to application deployment and approximately once a day as part of normal dyno management.

您可以对其进行写操作,但是在dyno重新启动时,任何更改都将丢失,这种情况经常发生.

You can write to it but any changes will be lost when your dyno restarts, which happens frequently.

根据您的用例,您应该使用数据存储(Heroku

Depending on your use case you should be using a data store (Heroku provides a PostgreSQL database by default, but there are other options) or a third-party file storage service like Amazon S3.

这篇关于更新一个html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆