Posted by Marcelo on Sabadini
21/02/2010
[Apache] mod_deflate: Reduce the load time of your pages
This article is a hook pulled from the article " Performance - less requets and more cache "of Michael Mafort .
Hello, today I will talk about a nice Apache configuration. It's mod_deflate .
Well, use the mod_deflate is a way to reduce the loading time of a page. But how does he do it?
When Apache receives a request to display a page it compact before sending to the client and this causes the data traffic is much lower. This is very efficient in HTML pages (but also other types of compact files).
When I talk pages include HTML pages. Php to generate HTML for an answer ok?
Apache will surely be a little slower to return the HTML for the fact of having to compress the response, but even so the page will load faster.
For Linux users becomes very easy to make this setting: Read the rest of this entry »
Posted by Marcelo on Sabadini
11/02/2010
Compress files with PHP
Hello, today I will show you how to compress file with PHP. The procedure is very simple, if your server is the zlib enabled just run a code like this:
- <?
- / **
- * Inserts a file within a zip.
- *
- * @ Param string $ name name_of_zip ZIP file that will be worked.
- * @ Param String $ path_file Path original file that goes to the ZIP
- * @ Param string $ file_name Name of file within the ZIP
- * @ Return Mixed
- * /
- $name_of_zip = null , $path_file = null , $file_name = null ) { fileToZip function ($ name_of_zip = null, $ path_file = null, $ file_name = null) {
- ; return 'All parameters are required';
- }
- / / Create the instance of ZIP
- ZipArchive; $ Zip = new ZipArchive;
- / / If unable to create the ZIP file
- $zip -> open ( $name_of_zip , ZIPARCHIVE:: CREATE ) === true ) { if ($ zip -> open ($ name_of_zip, ZIPARCHIVE:: CREATE) === true) {
- / / Add the file in the zip
- ( $path_file , $file_name ) ; $ Zip -> AddFile ($ path_file, $ file_name);
- ( ) ; // fecha a conexão com o ZIP $ Zip -> close () / / close connection with the ZIP
- / / Optionally you can delete the original file, just insert a variable in the parameters
- / / Unlink ('/ path / to / file / file.php');
- ; return true;
- { Else {}
- ; return false;
- }
- }
- ?>
Posted by Marcelo on Sabadini
06/02/2010
[Quickie] PHP - Do not write file. 'Inc'
If your Apache server is not configured correctly it causes files. Inc is displayed on the screen. Soon, the entire contents of the file is displayed in the browser.
Say you have a file in which the arrow of your system settings, such as: Host of the database, username and password.
Saved under the name config.inc.
By accessing this file directly by URL see what happens:



![config.inc being displayed in Firefox config.inc 300x178 [Rapidinha] PHP Não escreva arquivos .inc](http://marcelosabadini.com.br/blog/wp-content/uploads/2010/02/config.inc-300x178.jpg)
