- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在寻求帮助,以实现在 Go HTML 模板中自动包含版本化文件名的功能。例如,在我的模板中,头部有这样的内容:
<link rel="stylesheet" href="{{ .MyCssFile }}" />
样式表本身有一大块 MD5 散列附加到名称上,来自名为 gulp-rev 的 gulp 脚本
stylesheet-d861367de2.css
目的是确保浏览器能够获取新的更改,同时也允许缓存。下面是 Django 中的示例实现,以便更好地解释:
https://docs.djangoproject.com/en/1.9/ref/contrib/staticfiles/#manifeststaticfilesstorage
A subclass of the StaticFilesStorage storage backend which stores the file names it handles by appending the MD5 hash of the file’s content to the filename. For example, the file css/styles.css would also be saved as css/styles.55e7cbb9ba48.css.
The purpose of this storage is to keep serving the old files in case some pages still refer to those files, e.g. because they are cached by you or a 3rd party proxy server. Additionally, it’s very helpful if you want to apply far future Expires headers to the deployed files to speed up the load time for subsequent page visits.
现在我想知道如何在 Go 中最好地实现这一点?我打算提供来自内置 file server 的文件.
我目前的想法是:
最佳答案
写一个template function来解析名称。这是一个示例模板函数:
func resolveName(p string) (string, error) {
i := strings.LastIndex(p, ".")
if i < 0 {
i = len(p)
}
g := p[:i] + "-*" + p[i:]
matches, err := filepath.Glob(g)
if err != nil {
return "", err
}
if len(matches) != 1 {
return "", fmt.Errorf("%d matches for %s", len(matches), p)
}
return matches[0], nil
}
下面是注册为函数“resolveName”时如何在模板中使用它:
<link rel="stylesheet" href="{{ .MyCssFile | resolveName }}" />
此函数会在每次呈现模板时解析文件名。一个更聪明的函数可能会在解析名称时缓存名称,或者在启动时遍历目录树以预先构建缓存。
关于templates - Go HTML 模板中的自动 Assets 修订文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34558551/
为包含未推送变更集的 -r 选项指定修订/修订集的最佳方法是什么,这对于在本地克隆或在仅包含已推送变更集的存储库中创建书签很有用。 当您需要在工作中切换到其他您还没有准备好插入的事情时,通常需要这样做
我正在寻找一个合适的过程来保留数据库中行(及其关系)的修订或快照。 以电子商务平台为例- 客户创建订单。该订单与账单地址和送货地址相关联。 该客户随后更改了个人资料中地址簿中的地址。 原始订单的地址不
我喜欢 DocumentViewer 在 WPF 应用程序中显示 XPS 文档。但我还需要编辑 XPS 文档。我找到了用于编辑 XPS 的独立应用程序 (.exe)。我需要的是一个用于查看和编辑 XP
所以我目前正在分析我的 Spring Java 项目。我想做的一件事是计算文件/类已更改的次数。在 Eclipse 中,我可以右键单击一个类,选择 Team --> Show History,它会显示
目前我可以从没有纹理的 DAE 文件加载地球模型,只是为了显示屏幕上有东西。为此,我使用了 GLU。 但现在我正在尝试使用我们的GLM 和着色器 来加载带有纹理的模型。我遇到的问题是正确地让它们一起工
如何检查特定 Safari 二进制文件中使用了 webkit 的哪个修订版(svn 修订版)?例如,我想知道 Mac 上最新的 Safari(雪豹 10.6.7)使用的是哪个版本。 用户代理不提供此信
修订数据的存储方式每个受修订影响的对象在 _AUD 中都有一个单独的记录。 table 。因此,当我搜索影响对象的修订时 A ,我会找回修订版为3的条目用于对象 B , 但如果对象 A和/或 C修订版
在 git 中,您可以通过类似 master^^ 的方式引用修订版。 , 意思是 master 之前的两次修订。你能以某种方式(或通过某种扩展)在 Mercurial 中做同样的事情吗?例如,如果我想
我正在尝试使用 Python 2.7 对维基百科文章的内容如何随时间变化进行分析。我只对页面的内容感兴趣,发现最简单的方法是使用 Wikipedia package .我的代码成功加载了一篇文章,然后
我在 Alembic 中有一个依赖于特定后端的修订版,但语义并不明确依赖于它(只会让事情变得更快)。 我希望我的代码不依赖于特定的后端(即修改在运行时不会给出错误)。我应该在 def upgrade(
我有一个 Xcode 项目的本地 git 存储库。如何(从终端)将项目的特定修订 checkout 到不同的文件夹? 谢谢。 最佳答案 您可以将本地存储库克隆到另一个文件夹中: clone a spe
据我所知,git 通过保存更改的行来存储修订。运行文本文档,如文档或冗长的 LaTeX 文件,通常有很长的行或在 80 个字符后被强制中断。当一个词被更改时,它会导致更改行的巨大差异,从而使 git
我目前在我公司的官僚主义 hell 中,需要定义什么构成了我们测试程序的不同级别的软件更改。我们有一个我们内部遵循的粗略实践,但我正在寻找一个标准(如果存在)以在我们的质量体系中引用。我认识到开发人员
我已经开始使用 Hibernate Envers 来审计日志记录业务对象。我已经阅读了文档,并且从我看到的所有示例中,查询是通过修订号完成的。 我想按修订日期查询,即获取被审计实体在特定日期或日期范围
我正在构建一个网站,用户可以在其中更改其公开显示的个人资料。但是,我需要所有更改在上线之前都得到管理员的批准。在更改获得批准之前,他们的旧个人资料将显示。在管理员中应该有一个等待批准的配置文件列表。最
我正在构建一个网站,用户可以在其中更改其公开显示的个人资料。但是,我需要所有更改在上线之前都得到管理员的批准。在更改获得批准之前,他们的旧个人资料将显示。在管理员中应该有一个等待批准的配置文件列表。最
我编辑了这个问题,因为下面提到的答案是在使用 while 和 begin 时,它应该在存储过程中。 所以现在我在存储过程中运行它,但我仍然遇到错误。 counter; while counter <
我刚开始使用 Hibernate Envers 进行审计,我想知道是否有办法在两个日期之间获取一个类的所有修订。 到目前为止我一直在使用: AuditQuery query = reader.crea
我认为前缀++ 和后缀++ 之间的唯一区别是它们的优先级。显然我错了。也许重要的是返回值? 最佳答案 在 C++ 中,++++i 可以编译,因为前缀 operator++ 返回一个左值。但是,仍然不建
在 Jenkins 中,我使用 XML API 来获取提交的 SHA,例如 http://jenkins/view/job/test/470/api/xml?xpath=//lastBuiltRevi
我是一名优秀的程序员,十分优秀!