相同的样式表是否在不同的页面上多次加载?

时间:2022-08-31 08:45:24

I work on a large Intranet system - as it is an evolved system which started over ten years ago unfortunately the design of it isn't great and needs to be completely rewritten as it currently works by using frames.

我在大型Intranet系统上工作 - 因为它是十年前开始的一个演化系统,不幸的是它的设计并不好,需要完全重写,因为它目前使用框架工作。

The problem with the frame-based layout is that there's a "main" section which does the includes for the stylesheets. This is quite a simple question, but I've never found any evidence of it. Does that same stylesheet get loaded multiple times because it's on separate web pages? Or does the browser cache it and do a comparison check against same-named stylesheets. Is this the same for JavaScript libraries?

基于框架的布局的问题在于,有一个“主要”部分,用于处理样式表的包含。这是一个非常简单的问题,但我从来没有找到任何证据。是否会多次加载相同的样式表,因为它位于不同的网页上?或者浏览器是否对其进行缓存并对同名样式表进行比较检查。这对JavaScript库来说是一样的吗?

2 个解决方案

#1


Yes, browsers will load external scripts and stylesheets from cache for each frame, unless you deliberately break it by sending no-cache headers with those files.

是的,浏览器将从每个帧的缓存加载外部脚本和样式表,除非您通过向这些文件发送no-cache标头来故意破坏它。

#2


AFAIK the browser should always query its cache before making a http request (GET).
'always' being the operative word as we all know the problems with what browsers should and shouldn't do!
This rule should apply to any filetype that is requested by the browser.

AFAIK浏览器应始终在发出http请求(GET)之前查询其缓存。 “总是”是一个有效的词,因为我们都知道浏览器应该和不应该做的问题!此规则应适用于浏览器请求的任何文件类型。

#1


Yes, browsers will load external scripts and stylesheets from cache for each frame, unless you deliberately break it by sending no-cache headers with those files.

是的,浏览器将从每个帧的缓存加载外部脚本和样式表,除非您通过向这些文件发送no-cache标头来故意破坏它。

#2


AFAIK the browser should always query its cache before making a http request (GET).
'always' being the operative word as we all know the problems with what browsers should and shouldn't do!
This rule should apply to any filetype that is requested by the browser.

AFAIK浏览器应始终在发出http请求(GET)之前查询其缓存。 “总是”是一个有效的词,因为我们都知道浏览器应该和不应该做的问题!此规则应适用于浏览器请求的任何文件类型。