Is there a particular strategy to the Media folder in the repo?
Does one ignore this folder locally so all of it isn’t uploaded to GitHub?
I edit content locally in the Panel and whenever I’m ready to do a PR, all of the newly generated media/pages/… really make the PR unnecessarily crowded.
After reading this post I started to wonder, since it sounds like these files don’t need to be in the repo at all, and are only generated on the live server:
Also, what other directories can be ignored in the repo? Sessions?
I think there’s no correct answer and it mostly depends on the project and setup. For example, I have a repo for this project. Including the media is not even an option because that’s probably 15GB of data.
But I also excluded the content folder because they update the site using the panel and everything else is pushed live automatically using push to deploy.
On the other hand, my site is all stored in a private repo, including media and content folder. That’s because everything is pushed automatically live and I don’t use the live panel to edit the content.
There’s a few folders and files you definitely don’t want to have in a public repo: users and license for example. But other than that, it mostly depends on the project and setup.
Personally, I would never include the media folder in a repo, it just blows it up unnecessarily. The media folder–contrary to the content folder–is something that is re-generated automatically if you remove it and should be deleted when doing upgrades.
Well that’s not really true. The entire media folder is not re-generated every time. It would honestly be a crazy thing to do, especially on big sites. I can’t possibly imagine to ask the server to re-generate 15000 images every other week just because I updated Kirby. The panel portion of the media folder sure, I can delete and regenerate that.
Deleting the media folder shouldn’t be a big deal imho. Even stronger; you should feel confident when doing so. It’s “just” a cache layer.
As it gets rebuilt in increments (per page visit), the only thing that could hurt performance is pages that have a lot of (heavy) images on them. But when you have this kind of site, you’re probably better of anticipating for this and use hooks to resize on upload / use workers to pre-heat caches / …
In theory yes. In practice, if your site receives thousand of daily users and you have tens of thousand of images, unless you’re running on a very expensive vps you’ll just crash the server.
the media folder is regenerated wherever the installation is viewed, whether it be on a live server or locally, but it is needless to track it in GitHub.
the other folders that hold sensitive data such as:
– site/accounts/
– site/sessions/
– site/cache/
– site/config/.license files
…etc., (and should only be judiciously tracked, if at all, and only if it is in a private repo).