Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...