Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
204 views
in Technique[技术] by (71.8m points)

javascript - Updating a html file

I'm hosting my little project on Heroku.

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"> 

In the HTML file and it didn't help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Heroku's filesystem is ephemeral:

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.

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...