Increase Your Web Site Speed With .htaccess
You can speed up the sites by caching using the .htaccess file. Caching would improve the loading time of your site, as well as reduce the bandwidth usage on your host.
In order to implement caching on your website using Apache .htaccess file, at least one of the 2 modules, mod_expires and mod_headers, should be enabled in the server. You can prevent the contact with the server from happening at all by using the Expires header and the Cache-control header.
If a browser receives an image with the cache control headers that say the image can be considered fresh for 2 weeks, then for 2 weeks the image can be pulled directly from the browser’s (or proxy’s) cache on subsequent requests.This is noticeably faster than even a conditional GET and a 304 response from the server since there is no round trip. After two weeks, a conditional GET would be sent to the server to check the Last-Modified date, then again, no requests would be made for the duration of the specified freshness period.
Caching using mod_expires:
This module controls the setting of the Expires HTTP header and the max-age directive of the Cache-Control HTTP header in server responses. The expiration date can set to be relative to either the time the source file was last modified, or to the time of the client access.
These HTTP headers are an instruction to the client about the document’s validity and persistence. If cached, the document may be fetched from the cache rather than from the source until this time has passed. After that, the cache copy is considered “expired” and invalid, and a new copy must be obtained from the source.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A300
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A3600
ExpiresByType text/css A3600
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A300
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A604800
ExpiresByType application/pdf A604800
ExpiresByType text/html A300
</IfModule>
Caching using mod_headers:
This module provides directives to control and modify HTTP request and response headers. Headers can be merged, replaced or removed.
<IfModule mod_headers.c>
# YEAR
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$">
Header set Cache-Control "max-age=29030400"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# 45 MIN
<FilesMatch "\.(html|htm|txt)$">
Header set Cache-Control "max-age=2700"
</FilesMatch>
</IfModule>
Kevin Liang
CTO / SEO Guru
Canadian Web Hosting
http://www.canadianwebhosting.com/
Disable ASP.NET web.config inheritance
If you want to use separate web.config for child directories, then you have to disable ASP.NET web.config inheritance.
You will be able to disable inheritance from the root web.config file.
Add the attribute <location> .. </location> as follows in the web.config file of the root folder.
<?xml version="1.0"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.web>
<compilation debug="false" />
</system.web>
</location>
</configuration>
This way, any child application defined below this application will not use the current configuration.
cPanel Proxy
cPanel proxy is very helpful incase of networks behind firewalls. It allows users to access cPanel, WHM and Web Mail on port 80
The setup can be done in three simple steps:
- Proxy Installation
- WebServer Configuration
- DNS Configuration
Installation:
- ssh login to the server as root user.
cd /usr/local/src
wget http://cpanelproxy.net/cPanelProxy.zip
mkdir cpanelproxy
cd cpanelproxy
unzip ../cPanelProxy.zip
cd ..
chown nobody.nobody cpanelproxy -R
chmod 755 cpanelproxy -R
mv cpanelproxy /usr/local/share
Webserver(Apache) Configuration:
Edit the Apache configuration file(/usr/local/apache/conf/httpd.conf) and add Alias for cPanel, WHM and webmail.
ServerName cpanel.*
ServerAlias cpanel.* whm.* webmail.*
DocumentRoot /usr/local/share/cpanelproxy
DNS Configuration:
Add alias or CNAME records for the domains.
EX:
cpanel 14400 IN CNAME yourdomain.com.
webmail 14400 IN CNAME yourdomain.com.
ASP Recordcount with MySQL database
I was trying to use the Recordcount in asp with MySQL and always came up with -1. It took me sometime finding a solution. Apparently MySQL does not support Server Side Cursors. Here is a quick fix:
To make this work you will need to set the CursorLocation to 3:
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorLocation = 3
objRS.Open mySQL, objConn
Hope this helps!
Kevin Liang
CTO / SEO Guru
Canadian Web Hosting
http://www.canadianwebhosting.com/