Rails资产管道和摘要值 [英] Rails asset pipeline and digest values

查看:43
本文介绍了Rails资产管道和摘要值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道资产摘要值是如何精确计算的吗?如果我有两个包含其他所有包含的JS脚本的JS文件,那么如果没有更改任何内部脚本,每个文件将保持相同的摘要哈希吗?还是每次资产:precompile操作运行时都要计算一个新的摘要值?

Does anyone know how exactly the asset digest value is calculated? If I have two JS files which contain various other included JS scripts then will each file maintain the same digest hash if none of the inner scripts have been changed? Or is a new digest value calculated each time the assets:precompile operation is run?

推荐答案

导轨指南获取

当文件名是唯一的并且基于其内容时,HTTP标头可以 设置为鼓励到处缓存(无论是CDN,ISP还是 网络设备或网络浏览器中)保留自己的副本 内容.当内容更新时,指纹将改变. 这将导致远程客户端请求新的副本. 内容.这通常称为缓存清除.

When a filename is unique and based on its content, HTTP headers can be set to encourage caches everywhere (whether at CDNs, at ISPs, in networking equipment, or in web browsers) to keep their own copy of the content. When the content is updated, the fingerprint will change. This will cause the remote clients to request a new copy of the content. This is generally known as cache busting.

Rails用于指纹识别的技术是插入哈希 内容的名称通常在结尾处.例如CSS 可以使用文件的内容的 MD5摘要

The technique that Rails uses for fingerprinting is to insert a hash of the content into the name, usually at the end. For example a CSS file global.css could be renamed with an MD5 digest of its contents

这篇关于Rails资产管道和摘要值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆