【问题标题】:Is there a permalink to the latest version of gist files?是否有指向最新版本 gist 文件的永久链接?
【发布时间】:2018-02-14 19:39:57
【问题描述】:

我创建了一个包含两个文件的要点,我想将其原始版本用作查询其内容的应用程序的参考。这些内容将在 GitHub 上更新。

然而,我发现文件的 URL 会随着要点的每个版本而变化。 是否有指向 gist 中文件最新版本的永久链接?

【问题讨论】:

标签: github permalinks gist


【解决方案1】:

原始 gist URL 遵循以下模式:

https://gist.githubusercontent.com/[gist username]/[gist ID]/raw/[gist commit ID]/[file name]

要查看最新版本,只需删除 [gist commit ID] 部分:

https://gist.githubusercontent.com/[gist username]/[gist ID]/raw/[file name]

例如

https://gist.githubusercontent.com/mwek/9962f97f3bde157fd5dbd2b5dd0ec3ca/raw/user.js

请记住,端点已缓存,因此您的更新可能会稍有延迟。

【讨论】:

  • 您知道缓存版本需要多长时间才能更新为最新更改?
  • FWIW 看起来您可以通过将查询字符串附加到 url 来缓存缓存,例如https://gist.githubusercontent.com/mwek/9962f97f3bde157fd5dbd2b5dd0ec3ca/raw/user.js?cachebust=dkjflskjfldkf
  • 由于..人类的懒惰,该文件将(可能)以不正确的 MIME 类型提供。
  • 实际上似乎还需要删除结尾部分,否则您可能会由于某种原因获得旧版本的文件。所以它是:gist.githubusercontent.com/[gist username]/[gist ID]/raw/
  • 执行此操作需要什么用户权限?
猜你喜欢
  • 1970-01-01
  • 2019-07-08
  • 2021-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-18
相关资源
最近更新 更多