I would like to show a Youtube playlist, that I may update from time to time, on my Netlify Website. I could obtain the playlist info using ytpl.
In order to make the website fast I don’t want to cache the playlist info (JSON) on Netlify use the cached JSON during web page rendering. So I have 2 questions:
Is it possible that I could store the JSON on Netlify?
Is it possible that I schedule a playlist update everyday?
Since the first option hurts the webpage load speed, so this is something I would like to avoid. And yeah I think daily trigger would be great, but still I have no idea how to store the returned API result during build time. That info/example would be valuable. Thank you very much.
I initially thought I could create an Netlify Function to help getting the Youtube Playlist and store the JSON response as a local file and then use the local file when the web page is being loaded. I wouldn’t need any database.
Have you considered outputting the returned information in a local file in the build system’s filesystem, somewhere under the publish directory?
If this is done the playlist would then become specific to each deploy and updated as each deploy occurred. As each new deploy is published, it would contain the updated playlist at the time the deploy occurred. The site can then load the playlist using javascript to fetch the URL for that file.
Just a quick question. As I could run the fetch script during build time and put the json file in the publish directory. Would it be possible that I could create an API that store the result in the publish directory, after it is being deployed?
Hi, @winstonma, deploys on Netlify are immutable. There is no way to change an existing deploy. Even if you created an API, there is no way to update a single file on a deployed Netlify site.
The only way to update a published site at Netlify is to create a completely new deploy with all required files and updates. Then that new deploy can be published.
A happy medium might be to do daily deploys to publish an update list once a day and also develop an API to update that list via javascript. The site could then load the file version of the list first and then, after that is complete, check the API to see if a newer version exists and, if so, update the playlist in the background.
I am testing Netlify CMS. I just deployed the sample site onto Netlify. It seems allow me to make changes on the site. It fits my need of editing on a more or less static site. I think I will migrate my tiny site to this.