开发者

Web Speed: it's worth it to put every included file in only one?

I am doing some tests (lamp):

Basically I have 2 version of my custom framework.

  • A normal version, that includes ~20 files.
  • A lite version that has everything inside one single big file.

Using my lite version more and more i am se开发者_如何学Pythoneing a time decrease for the load time. ie, from 0.01 of the normal to 0.005 of the lite version.

Let's consider just the "include" part. I always thought PHP would store the included .php files in memory so the file system doesn't have to retrieve them at every request.

Do you think condensing every classes/functions in one big file it's worth the "chaos" ? Or there is a setting to tell PHP to store in memory the require php files?

Thanks

(php5.3.x, apache2.x, debian 6 on a dedicated server)


Don't cripple your development by mushing everything up in one file.

A speed up of 5ms is nothing compared to the pain you will feel maintaining such a beast.

To put it another way, a single incorrect index in your database can give you orders of magnitude more slowdown.

Your page would load faster using the "normal" version and omitting one 2kb image.

Don't do it, really just don't.


Or you can do this:

  1. Leave the code as it is (located in many different files)
  2. Combine them in one file when you are ready to upload it to the production server

Here's what i use:

cat js/* > all.js
yuicompressor all.js -o all.min.js

First i combine them into a single file and then i minify them with the yui compressor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜