[英]What is static content in relation to web server?
Nginx is declared as a considerably faster server than Apache in serving static content . 在提供静态内容方面, Nginx被声明为比Apache更快的服务器。
Is JavaScript code static or dynamic content? JavaScript代码是静态内容还是动态内容?
"Static" means that the data is exactly the same for each and every request, which is opposed to "dynamic" responses which are generated individually for each request by a server side program (eg PHP, Python, Ruby, C#, any CGI script etc.). “静态”是指每个请求的数据完全相同,这与服务器端程序 (例如PHP,Python,Ruby,C#,任何CGI脚本)针对每个请求分别生成的“动态”响应相反等等。)。 In other words, anything that just sits on disk as a file and is served as is is static data;
换句话说,任何只是作为文件放在磁盘上并按原样提供的东西都是静态数据。 anything that invokes a server side program is not.
没有调用服务器端程序的任何东西。
Yes, Javascript files are static data as far as the web server is concerned, since the web server is just serving the Javascript file as is, it doesn't interpret or run it*. 是的,就Web服务器而言,Javascript文件是静态数据,因为Web服务器只是按原样提供Javascript文件,因此它不会解释或运行它。
* Unless it does, of course, via node.js or such. *除非这样做,否则当然是通过node.js等。
Static content is plain files like html, images, css, js 静态内容是纯文本文件,例如html,images,css,js
Pure javascript code files are considered static content when the bytes are served directly from the server without any modification (like templating/transpiling/generation). 当直接从服务器提供字节而不进行任何修改(例如,模板化/编译/生成)时,纯javascript代码文件被视为静态内容。
Static resources can usually be cached. 通常可以缓存静态资源。
Dynamic means the bytes are generated/modified by the server and thus not simply served as-is. 动态意味着字节是由服务器生成/修改的,因此不能简单地按原样提供。 Usually dynamic content is html server-side templates, generated image graphs and such.
通常,动态内容是html服务器端模板,生成的图像图等。
NOTE: it has nothing to do with javascript being a dynamic language 注意:与javascript是动态语言 无关
NOTE: any dynamic changes occuring inside the browser are not considered 注意:不考虑浏览器内部发生的任何动态变化
Static Content 静态内容
Static content is published to regular files eg images, JavaScript, CSS on your server and handled using the simplest methods available to the web server.The content remains the same for every request. 静态内容会发布到服务器上的常规文件(例如图像,JavaScript,CSS)中,并使用网络服务器可用的最简单方法进行处理。每次请求的内容都保持不变。
The advantages of static content are: 静态内容的优点是:
it is the fastest and most efficient way to deliver content 这是最快,最有效的内容交付方式
it does not require any code to execute or any databases to be 它不需要任何代码来执行或不需要任何数据库
accessed, which makes it the most secure way to deliver content 访问,这使其成为传递内容的最安全方式
it uses simple, clean URLs to address the content 它使用简单,干净的URL来处理内容
it takes best advantage of web caching systems, which further boosts performance 它充分利用了Web缓存系统的优势,从而进一步提高了性能
it is compatible with every type of webserver technology 它与每种类型的Web服务器技术兼容
However, it also has the following disadvantages: 但是,它也具有以下缺点:
it must be republished when it changes, or your viewers will not see the updates 更改时必须重新发布它,否则观众将看不到更新
it cannot display differently to different viewers, depending on 它不能向不同的观看者显示不同的内容,具体取决于
their login status or other factors 他们的登录状态或其他因素
Dynamic Content 动态内容
Dynamic content is generated for you at the time you request the page. 在请求页面时会为您生成动态内容。 The document you view exists only for you at that moment;
您查看的文档仅在那时存在。 if viewed by someone else at the same time, or by you at a slightly different time, you could get something different.
如果同时有人查看您,或者您在稍微不同的时间查看,您可能会有所不同。
Dynamic content is good for: 动态内容有益于:
However, dynamic content has the following disadvantages: 但是,动态内容具有以下缺点:
Is JavaScript code static or dynamic content? JavaScript代码是静态内容还是动态内容?
Yes the Javascript files residing on the server are considered to be static. 是的,驻留在服务器上的Javascript文件被认为是静态的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.