Continuing to take advantage of the Apache web server, we will activate the mod_expires module. This module sends a message to the client machine about the document's validity, and the client can store a cache of the site until the client receives a new message from the server expiration of data. This technique increases the speed of download.
To activate this feature, you can open the .htaccess file available in the Magento root directory and enter this block of code:
<IfModule mod_expires.c>
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
ExpiresActive On
ExpiresDefault "access plus 1 year"
</IfModule>For further information about the .htaccess configuration, follow the link at http://httpd.apache.org/docs/2.2/mod/mod_expires.html.
Increasing PHP memory by host configuration has a direct relationship with your contracted hosting service. Some shared hosting services do not give this option to the developers. This is one of the main reasons to choose a specialized Magento hosting service.
Generally, this configuration can be done by adding the following code to the .htaccess file available in the Magento root directory:
<IfModule mod_php5.c> ############################################ ## adjust memory limit php_value memory_limit 256M php_value max_execution_time 18000 </IfModule>
MySQL has the query cache feature to provide fast queries on a database. Once again, you need to conduct deep research on your possible hosting services before contracting any to make sure you have all the services you need for a great production environment.
Before starting the optimization, refer to the PHP and MySQL documentations of your hosting service to check the availability of these changes.
Open the php.ini hosting service file and place these configurations:
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
max_execution_time = 30 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 512M ; Maximum amount of memory a script may consume (8MB)
query_cache_size = 64M
[MySQLi]
; Please refer to http://php.net/manual/en/mysqli.configuration.php for further information
; Maximum number of persistent links. -1 means no limit.
mysqli.max_persistent = -1
; Allow accessing, from PHP's perspective, local files with LOAD DATA statements
;mysqli.allow_local_infile = On
; Allow or prevent persistent links.
mysqli.allow_persistent = On
; Maximum number of links. -1 means no limit.
mysqli.max_links = -1
; If mysqlnd is used: Number of cache slots for the internal result set cache
mysqli.cache_size = 2000
; Default port number for mysqli_connect(). If unset, mysqli_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
; at MYSQL_PORT.
mysqli.default_port = 3306
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysqli.default_socket =
; Default host for mysql_connect() (doesn't apply in safe mode).
mysqli.default_host =
; Default user for mysql_connect() (doesn't apply in safe mode).
mysqli.default_user =
; Default password for mysqli_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysqli.default_pw =
; Allow or prevent reconnect
mysqli.reconnect = OffNow, let's configure the query_cache_size variable directly on the MySQL database.
Open the phpMyAdmin web SQL console, and execute the SHOW VARIABLES LIKE 'query_cache_size'; query without selecting a database. The query will probably return the 0 value for the query_cache_size variable.
Execute the SET GLOBAL query_cache_size = 1048576; query and execute SHOW VARIABLES LIKE 'query_cache_size'; again.
The query will probably return the following information:

The query_cache_size variable was activated with success!
For further information about the MySQL cache size configuration, follow the link at https://dev.mysql.com/doc/refman/5.0/en/query-cache-configuration.html.
Even by testing these configurations in your localhost environment, you can feel the huge positive difference between the first access in your Magento installation and the last access after the configuration. This is really awesome!