天道酬勤,学无止境

server-side-includes

Server side include breaks layout

I have finally perfected my web page and it works perfectly in every browser. However, when I abstracted out the header and footer contents into server side includes, the layout changes marginally in Firefox/Opera/Safari, but in IE, the layout changes makes the page look broken. Are there any known issues that could cause the layout to change when using SSIs? Quite frankly, I'm surprised that using a SSI would have an effect like this. I am using HTML5 tags, the modernizr js library, and the page validates if any of that matters. EDIT: I fixed my problem by changing what code was abstracted (I

2021-06-26 14:06:01    分类:问答    html   server-side-includes

使用太多的 PHP 包括一个坏主意?(Using too many PHP includes a bad idea?)

问题 我的问题是使用多个 PHP includes() 是否是一个坏主意。 我问的唯一原因是因为我总是听说站点上有太多样式表或脚本会创建更多 HTTP 请求并减慢页面加载速度。 我想知道关于 PHP 的同样情况。 回答1 详细回答: 网页中引用的每个 CSS 或 JS 文件实际上都是由浏览器通过网络获取的,这通常涉及 100 毫秒或更长时间的网络延迟。 对同一服务器的请求(按照惯例,虽然不是强制性的)一次序列化一两个,因此这些延迟会累积起来。 另一方面,PHP 包含文件都是在服务器本身上处理的。 而不是 100 毫秒,本地磁盘访问将是 10 毫秒或更短,如果缓存,将是更快的直接内存访问。 如果您使用 http://eaccelerator.net/ 或 http://php.net/manual/en/book.apc.php 之类的东西,那么您的 PHP 代码将在服务器上预编译一次,甚至不会无论您是包含文件还是将它们全部转储到一个地方。 简短的回答: 别担心。 100 次中有 99 次出现此问题,更好的代码组织带来的好处超过了性能提升。 回答2 使用包含有助于代码组织,并且本身没有障碍。 如果你加载了一堆你不需要的东西,那会减慢速度——但这是另一个问题。 说明:当您包含页面时,请注意您添加到负载中的内容; 不要粗心地包含不需要的资源。 回答3 如前所述,使用多个 PHP

2021-06-23 20:17:58    分类:技术分享    php   include   server-side-includes

SSI or PHP Include()?

basically i am launching a site soon and i predict ALOT of traffic. For scenarios sake, lets say i will have 1m uniques a day. The data will be static but i need to have includes aswell I will only include a html page inside another html page, nothing dynamic (i have my reasons that i wont disclose to keep this simple) My question is, performance wise what is faster <!--#include virtual="page.htm" --> or <?php include 'page.htm'; ?>

2021-06-05 02:35:53    分类:问答    php   apache   server-side-includes

ASP.NET Directive Convention for Declaring Client-Side Includes

I am loading .aspx and .ascx files as StreamReader. I want each file to register it's javascript and stylesheet dependencies in some declaration like a <%@ ClientDependency path="~/Scripts/jquery-1.4.1.min.js" %>. Is there an existing convention for doing such a thing? I don't need an implementation, but I don't want to create a new syntax if there is already a way to do it. Also, what are the guidelines for custom <%@ blocks in ASP.NET? Also, please retag this question if you can think of a more appropriate description.

2021-06-03 18:16:37    分类:问答    javascript   asp.net   asp.net-mvc-2   server-side-includes   page-directives

Varnish and ESI, how is the performance?

Im wondering how the performance of th ESI module is nowadays? I've read some posts on the web that ESI performance on varnish were actually slower than the real thing. Say i had a page with over 3500 esi includes, how would this perform? is esi designed for such usage?

2021-06-02 04:15:22    分类:问答    caching   reverse-proxy   varnish   server-side-includes   edge-side-includes

在不使用mod_rewrite的情况下运行没有扩展名的PHP?(Running PHP without extension without using mod_rewrite?)

问题 使用Apache 2.2和PHP 5,在没有.php扩展名的情况下运行PHP的最佳方法是什么? 例如,我有一个名为app.php的脚本,我喜欢将其调用为: http://example.com/app 请注意,我仍然要保留.php扩展名,并且没有mod_rewrite 。 也不要使用index.php ,因为它需要太多目录。 我确实找到了一种方法,将其添加到我的.htaccess , AddHandler server-parsed .php SetHandler application/x-httpd-php AddHandler application/x-httpd-php .php 通过使用此页面,页面运行会稍微慢一些。 我怀疑它会在每个PHP页面上调用SSI。 想知道是否有更好的方法来完成此任务。 回答1 另一种方法是使用内容协商。 打开多视图: Options +MultiViews 如果不存在命名资源,则Apache将遍历该文件,然后根据浏览器发送的媒体类型和内容编码要求进行排序。 如果只有一个文件(您的PHP脚本),那么URL就是解析的文件。 回答2 您还可以在.htaccess强制指定文件的mime类型: <Files app> ForceType application/x-httpd-php </Files> 回答3 简短的答案是

2021-05-25 10:33:30    分类:技术分享    php   mod-rewrite   apache   server-side-includes

Can I include a PHP file in an SHTML file and store the result in a SHTML variable?

I want to include a PHP file in an SHTML file and store the result in a SHTML variable and include different things depending on the result. Example: Assume the PHP script would echo 0/1 in plain text (depending on something like time or something). And then in the SHTML, I'd like to store the output of that PHP file in a SHTML variable. Then if the value stored in that variable is 1, include fileA.html, else include fileB.html.

2021-05-14 05:10:41    分类:问答    php   variables   server-side-includes   ssi   shtml

包含函数文件的效率(在PHP中)(Efficiency for including files of functions (in PHP))

问题 如果我有大量功能,最好将它们全部保存在一个大文件中,或者将它们分成几个具有相关功能的文件会更好。 更好的是,对于可维护性和处理请求的服务器而言,效率更高。 例如,现在我所有文件都包含在名为include.php文件中。 但是,最好有一个包含include的include文件,例如: <?php include('/functions/user.php'); include('/functions/admin.php'); include('/functions/content.php'); include('/functions/nav.php'); include('/functions/database.php'); include('/functions/other_junk.php'); ?> 回答1 为了可维护性,请绝对将它们分开。 我怀疑性能是否会受到影响,但是即使这样做(只是一点点),您最好还是编写可维护的,可读的代码。 回答2 您需要确定使用的是XCache或APC之类的PHP缓存。 这样,您的PHP文件应该全部位于内存中,并且您完全不必担心其中的文件会碰到磁盘。 如果您将喜欢的函数/类分解为自己的文件,我肯定会发现它更容易。 回答3 在可维护性方面,通常最好将您的功能分成相关的组。 (就像您在上面显示的那样, user.php仅仅是与用户相关的功能)。

2021-04-29 22:16:31    分类:技术分享    php   performance   include   server-side-includes

Using too many PHP includes a bad idea?

My question is whether or not using multiple PHP includes() is a bad idea. The only reason I'm asking is because I always hear having too many stylesheets or scripts on a site creates more HTTP requests and slows page loading. I was wondering the same about PHP.

2021-04-29 00:36:02    分类:问答    php   include   server-side-includes

How do I limit PHP apps to their own directories and their own php.ini?

I am running multiple PHP apps on my Mac, running OS X 10.5.6, Apache 2, PHP 5. I have subdomains setup for each project, a host file entries for each subdomain, and Virtual Directory blocks in the Apache config. So project1.localhost goes to /Library/WebServer/Documents/Project1 project2.localhost goes to /Library/WebServer/Documents/Project2 etc... However, this method doesn't really "isolate" the web apps. For example, if I include a script like so: <?php include("/includes/include.php"); ?> It references the script from the base directory of my computer. So it accesses C:/includes/include

2021-04-27 06:02:36    分类:问答    php   apache   include   subdomain   server-side-includes