Absolutely Tech

[HowTo] Extend phpmyadmin session expiration time

Recently, I got frustrated being logged out every few minutes (24 minutes, to be precise) from phpmyadmin on my localhost. I make some db changes, write some code and when I get back to phpmyadmin, I would see my session had expired. To fix this, I changed the configuration so that my session would expire only after 24 hours of inactivity.

Steps to follow:

  • Copy the following code at the end of /etc/phpmyadmin/config.inc.php:
    $cfg['LoginCookieValidity'] = 60*60*24;
    ini_set('session.gc_maxlifetime', $cfg['LoginCookieValidity']);

This will let your session expire only after 60*60*24 seconds, that is one day.

Cheers!

[HowTo] Add expires headers to cache static files using htaccess

Caching is one of the most important things to keep in mind when you are developing a website which is expected to get large amount of visitors. Most web developers neglect caching, some even don’t know correct ways to implement it.

In this tutorial, I’ll show you how to enable browser cache of static files simply using htaccess file. Basically server adds the Expires header to file-type you specify. Expires header will make sure the browser stores the file locally and use the same file until the time mentioned in expires header has passed.

Before we move ahead, please make sure apache’s mod_expires is loaded. You can check it using phpinfo() under ‘Loaded Modules’ section. If you don’t find it there, you can see this tutorial to enable mod_expires.

Copy the following code and paste it into .htaccess file in your website’s root directory.

# Turn on the Expires engine
ExpiresActive On
 
# Expires after a month client accesses the file
ExpiresByType image/jpeg A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/plain A2592000
 
# Good for one week
ExpiresByType application/x-javascript M604800
ExpiresByType text/css M604800
ExpiresByType text/html M604800

Explanation:

ExpiresActive On turns on the expires engine. ExpiresByType image/jpeg tells server to check if MIME-type of file is image/jpeg. If yes, set the expires header.
Read the rest of this entry »

[HowTo] Enable or disable modules in Apache

You can enable or disable any apache module using a2enmod and a2dismod. You don’t need to edit the conf file for that unless you are having some problem with this method. The syntax of these commands is really simple:
To enable a module:

sudo a2enmod module_name

To disable a module:

sudo a2dismod module_name

Read the rest of this entry »