Compress php script before upload to main server
How can we compress php script before upload to main server so that our web site will become so fast to browse &开发者_StackOverflow中文版 reduce page downloading time..?
Thanks.
PHP runs entirely on the server-side, so compressing it will not reduce page download time.
You can't. You probably meant to compress the output of your website. You can add a mod GZIP handler to your Apache configuration, provided you run your site on Apache. Add the following to your .htaccess file:
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>
Compressing a PHP file will not speed up it's execution time.
By default, PHP will read the entire file each time, compile it to bytecode, then run that bytecode.
What you are probably looking for is a bytecode cache like APC. It will cache the bytecode that is generated so it does not need to be created each time.
We've used NuSphere PhpExpress - Free PHP accelerator (http://www.nusphere.com/products/index.htm). It compiles PHP. It also requires an extension add-on for the server. It does speed pages up (a LITTLE), and it also protects them from being 'shared' (as the code is 'hidden').
There are better ways to increase the speed of you website though (see post by TheGrandWazoo) or by making sure your database table are optimized, queries and pages cached when feasible.
精彩评论