Skip to content

Instantly share code, notes, and snippets.

@atenni
Last active December 20, 2024 02:20
Show Gist options
  • Save atenni/5604615 to your computer and use it in GitHub Desktop.
Save atenni/5604615 to your computer and use it in GitHub Desktop.
How to permalink to a gist's raw file
@barraIhsan
Copy link

I'm also wondering how did he get SO SHORT url (with short hash) in the first place:

https://gist.github.com/atenni/5604615

I'm suspecting back in 2013 Github allowed to use such shorter urls, and it's now impossible to make. But I wonder if I'm wrong

yeah maybe

@Kuju29
Copy link

Kuju29 commented Mar 3, 2021

This is URL worked for me. It will update after 4-5 min, I think so.

https://gist.githubusercontent.com/King1037/bd9861c08b86ac158d426ac91d14995d/raw/d956873ea1468sdfcca425c6cb2d0f7b63f8f4cdd/Ldsdfyer.fd.css

You just delete the text after Raw.
https://gist.githubusercontent.com/USERNAME/GIST_ID/raw
https://gist.githubusercontent.com/King1037/bd9861c08b86ac158d426ac91d14995d/raw

@0x49D1
Copy link

0x49D1 commented Mar 17, 2021

Thanks, that was nice: works for secret gists too.

@rjb3977
Copy link

rjb3977 commented Apr 3, 2021

You can use query parameters to get around caching if you want fast updates, i.e. every time you make a request append something like ?cache-bust=(some random url-safe string) to the URL. As far as I can tell, any query string works, so you can omit the cache-bust= if you want, or use donkey-poo= if you feel so inclined.

@revolter
Copy link

revolter commented Apr 3, 2021

@rjb3977, usually, an underscore and the current timestamp are used for this: ?_=1617443829.

@AlexAtkinson
Copy link

I found this discussion after looking into it myself. Here's what I've got:

  • GIST is NOT meant to behave like a repository. It is a Front End technology.
  • Without cache busting, updates take quite a while... Longer than I was going to wait to measure how long exactly.
  • WITH cache busting, you can reduce the latency of updates to ~30-60s, but there IS STILL LATENCY.

Here's what I used to observe and measure changes.
Note that I was adding a, b, c... to line 4 character 1 (after the pound/hash sign) every time I saw the change in the cli.

while true; do line=$(curl -s https://gist.githubusercontent.com/raw/2bf5c315a7895193ddc3fe647ef3976b/detect-ci.sh?cache-bypass=$(date +%s) | sed '4q;d'); echo "$(date) -- ${line:1:1}"; sleep 1; done

So, this should be good enough for MOST applications. Mileage may vary.
And there's always a risk that GH will change their caching behavior for these assets.

@kleinlennart
Copy link

Nice. Exactly what I needed, thank you! 🙏
I think this should be the default URL, or GitHub should at least be more explicit about this difference...

@YaoYinYing
Copy link

wow, you are my time saver!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment