Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: Add a "file proxy format" #5752

Open
bep opened this issue Mar 13, 2019 · 4 comments
Open

proposal: Add a "file proxy format" #5752

bep opened this issue Mar 13, 2019 · 4 comments

Comments

@bep
Copy link
Member

bep commented Mar 13, 2019

This is related to #5749 -- but I think that concept has a wider potential even if the title of this issue may seem a little out there (I just made it up quickly), so I quickly jot down some thoughts here.

version https://git-lfs.github.com/spec/v1
oid sha256:e6df77690697794deacb9d6963e574044448bef923f7d688aab1d856c54388a3
size 4074082

The above is an example of a Git LFS placeholder for an image. It doesn't say where to find the image, but I guess it assumes to be in the current "Git LFS" repo.

We will add remote support for resource.Get so you can do {{ resource.Get "https://bep.is/sunset.img }} etc. which is super cool, but has some limitations:

  • Without additional information we would have to download the file (or an ETag) on every build to check if it has changed.

  • It would not work in page bundles.

    If we could create a bundle:

my-bundle
├── index.md
└── sunset.jpg

And sunset.jpg would contain something ala:

version https://gohugo.io/resources/v1
source: https://bep.is/sunset.jpg
sha256:e6df77690697794deacb9d6963e574044448bef923f7d688aab1d856c54388a3
size 4074082

The above would probably need some help from some utility (like hugo fetch image) because it would be too hard to write by hand. But it has some benefits:

  1. It is very generic and could be used for anything.
  2. The SHA256 would allow for very fast cache evaluation.
  3. It would take almost no place on disk, and could be copied freely if you need to use the image etc. in another bundle.
  4. We could add metadata to it (title, params etc.)
@bep bep added the Proposal label Mar 13, 2019
@bep bep added this to the v0.56 milestone Mar 13, 2019
@moorereason
Copy link
Contributor

Interesting idea. Random comments:

Without additional information we would have to download the file (or an ETag) on every build to check if it has changed.

If the hosting server allows it, we could use HTTP HEAD to retrieve headers without the body.

Are you proposing to cache these resources elsewhere in the project and commit the cache to git? I'm concerned about reproducible builds.

I'd tweak the format just a tad to add a hash keyword. Here's an ETag MD5 example:

version https://gohugo.io/resources/v1
source https://bepsays.com/assets/img/hugotree.jpg
hash md5:b426aee4ccaa45c03baa2b6c301cf371
size 333526

@bep
Copy link
Member Author

bep commented Mar 14, 2019

Are you proposing to cache these resources elsewhere in the project and commit the cache to git? I'm concerned about reproducible builds.

No, I'm proposing to use the existing file cache in Hugo, which can be used however you will:

  • Commit to Git
  • Configure to use Netlify's (or Circle CI etc.) file cache -- this is what I primarily have in mind
  • Use a /tmp folder for cache

Note that with remote resources there will be plenty of error scenarios, but the "reproducible builds" would be bulletproof when it works (assuming you trust SHA256).

@bep bep modified the milestones: v0.56, v0.57 Jun 14, 2019
@bep bep modified the milestones: v0.57, v0.58 Jul 31, 2019
@bep bep modified the milestones: v0.58, v0.59 Aug 13, 2019
@bep bep modified the milestones: v0.59, v0.60 Sep 6, 2019
@bep bep modified the milestones: v0.60, v0.61 Oct 21, 2019
@bep bep modified the milestones: v0.61, v0.62, v0.63 Nov 25, 2019
@bep bep modified the milestones: v0.63, v0.64 Dec 11, 2019
@bep bep modified the milestones: v0.64, v0.65 Jan 22, 2020
@bep bep modified the milestones: v0.65, v0.66 Jan 30, 2020
@bep bep modified the milestones: v0.66, v0.67 Mar 2, 2020
@bep bep modified the milestones: v0.67, v0.68 Mar 9, 2020
@bep bep modified the milestones: v0.113.0, v0.115.0 Jun 13, 2023
@bep bep modified the milestones: v0.115.0, v0.116.0 Jun 30, 2023
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@bep bep modified the milestones: v0.125.0, v0.126.0 Apr 23, 2024
@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants