English 中文(简体)
我怎么能够加快我以购买力平价为基础的网站?
原标题:How can I speed up my PHP based website?

我刚刚从头,、朝 y建造了一个小型的PHP站点。 但是,鉴于其规模,它比我预期的要慢一些。

我有这样的文件/文件:

  • articles [folder]
  • css [folder]
  • html [folder]
  • images [folder]
  • js [folder]
  • photography [folder]
  • resources [folder]
  • articles.php [file]
  • bio.php [file]
  • contact.php [file]
  • content.php [file]
  • favicon.ico
  • footer.php [file]
  • header.php [file]
  • index.php [file]
  • photography.php [file]

我的大多数PHP档案都是这样编造的:

<?php

$thisPage="Writing";

include("header.php");


$page = $_GET[ article ];
$file = "articles/".$page.".html";
if(file_exists($file)) {
  include($file);
} else {
  print "404 Error. Page does not exist";
}

function IsSafeInclude($x) {
    if(strpos($x, "/../") !== false || strpos($x, "../") === 0 || strpos($x, "/..") == (strlen($x) - 3) || $x ==  .. )
        return false;
    else
        return true;
}

//include("html/articles-left.html");

?>

<div id="article-nav-container">

        <ul id="article-nav-pg">
            <li><a href="articles.php?article=article_name1">1</a></li>
            <li><a href="articles.php?article=article_name2">2</a></li>
            <li><a href="articles.php?article=article_name3">3</a></li>
            <li><a href="articles.php?article=article_name4">4</a></li>
            <li><a href="articles.php?article=article_name5">5</a></li>
            <li><a href="articles.php?article=article_name6">6</a></li>
        </ul>

        <script type="text/javascript">
                $(document).ready(function() {
            var loc = window.location.href; // The URL of the page we re looking at
            $( #article-nav-pg a ).each(function() {
                if (loc.indexOf(this.href) !== -1) { // If the URL contains the href of the anchor
                        $(this).addClass( selected ); // Mark it as selected
                }
            });
        });
        </script>



    </div><!-- end articles nav -->


    <p id="left-description"><img src="images/side-descrip-stories.jpg" width="20" height="90" alt="Story Description" /></p>

<?php

include("footer.php");

?>

一些档案中还有直接内部的html代码。 我将赞赏就如何提高我小型的PHP站点的速度提出任何建议。

增 编

最佳回答

首先,需要衡量:

  • how slow is "slow"?
  • is slow consistent?
  • does the site become very very slow when many users visit it?

然后发现瓶颈、设计变化、实施变革和再次采取措施。 在某些时候,你应说明你想改进事情以及为此做些什么。

瓶颈大多是数据库。 数据库查询优化是整个书的主题,但如果使用MySQL,请看 rel=“nofollow noreferer”>。 为量化网站的性能特征,请查阅

www.un.org/Depts/DGACM/index_french.htm 因此,你需要衡量并向我们提供一些数据。 该页有多少时间可以开始?

但是,在完全无关的注解中,需要仔细阅读

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签