Apache
Wednesday, March 7, 2012
Tuesday, March 6, 2012
RLimits
RLimits
Resource
limits, or RLimits, are sometimes appropriate on older hardware, or if a
customer requests them specifically. It can only be set on VPS/Dedicated servers.
RLimits can be added to :-
# /usr/local/apache/conf/include/pre_main_global.conf
The
most common entries are: Limits memory usage to 100MB. (note: will not work on
VZ VPS)
RLimitMEM
104857600 104857600
Limits
CPU usage.
RLimitCPU
150 200
Limits
Number of processes per user (This is what regulates the process limits on
shared servers).
RLimitNPROC
25 30
Mod_Expires/_Cache/_PageSpeed/_Bandwidth/_
Mod_Expires
The
mod_expires module allows Cache-Control and expires headers to be added to a
site without any changes to the existing site code. You can determine if a site
is already providing cache headers by checking the current site headers: No
caching headers:
~
$ curl -I http://www.hostgator.com
HTTP/1.1 200 OK
Date: Wed, 22 Sep 2010 20:30:25 GMT
Server: Apache/2.2.3 (CentOS)
Accept-Ranges: bytes
Content-Type: text/html; charset=UTF-8
HTTP/1.1 200 OK
Date: Wed, 22 Sep 2010 20:30:25 GMT
Server: Apache/2.2.3 (CentOS)
Accept-Ranges: bytes
Content-Type: text/html; charset=UTF-8
Cloudflare's
caching headers:
HTML:
HTTP/1.1 200 OK
Server: cloudflare-nginx
Date: Wed, 22 Sep 2010 20:19:51 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
ETag: "a568013-14dd2-490de3c42e8c0"
Accept-Ranges: bytes
Cache-Control: max-age=300, must-revalidate
Expires: Wed, 22 Sep 2010 20:24:48 GMT
Image:
HTTP/1.1 200 OK
Server: cloudflare-nginx
Date: Wed, 22 Sep 2010 20:19:56 GMT
Content-Type: image/jpeg
Connection: keep-alive
Last-Modified: Tue, 03 Aug 2010 03:10:53 GMT
ETag: "a5683b0-10558-48ce2aa35e940"
Accept-Ranges: bytes
Content-Length: 66904
Expires: Wed, 22 Sep 2010 22:19:56 GMT
Cache-Control: max-age=7200
HTTP/1.1 200 OK
Server: cloudflare-nginx
Date: Wed, 22 Sep 2010 20:19:51 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
ETag: "a568013-14dd2-490de3c42e8c0"
Accept-Ranges: bytes
Cache-Control: max-age=300, must-revalidate
Expires: Wed, 22 Sep 2010 20:24:48 GMT
Image:
HTTP/1.1 200 OK
Server: cloudflare-nginx
Date: Wed, 22 Sep 2010 20:19:56 GMT
Content-Type: image/jpeg
Connection: keep-alive
Last-Modified: Tue, 03 Aug 2010 03:10:53 GMT
ETag: "a5683b0-10558-48ce2aa35e940"
Accept-Ranges: bytes
Content-Length: 66904
Expires: Wed, 22 Sep 2010 22:19:56 GMT
Cache-Control: max-age=7200
Note
how the image is being cached for 2 hours while the html is only being cached
for 5 minutes. You can reproduce those settings with the following .htaccess
rules.
header set Cache-Control "max-age=2592000"
</filesmatch>
<filesmatch "\.(css|js|pdf|txt)$">
header set Cache-Control "max-age=604800"
</filesmatch>
<filesmatch "\.(html|htm)$">
header set Cache-Control "max-age=43200"
</filesmatch>
<filesmatch "\.(cgi|fcgi|php|pl|scgi|spl)$">
header unset Cache-Control
<ifmodule mod_expires.c>
expiresactive off
</ifmodule>
</filesmatch>
<ifmodule mod_expires.c>
expiresdefault "access plus 1 year"
</ifmodule>
Mod_Cache and Mod_Pagespeed
mod_pagespeed
mod_pagespeed is an Apache module that adjusts html output to help the page
render faster in the clients browser and performs some caching for the output
as well. Some of the more common tasks would be removing whitespaces between
html code, unifying CSS and java scripts into one file, gziping and rearranging
the html on the page.
Install script:
GET
http://hgfix.net/heckel/install-pagespeed | bash
Mod_Bandwidth :-
"Mod_bandwidth"
is a module for the Apache HTTP webserver that enable the setting of server-wide or
per connection bandwidth limits, based on the directory, size of files and
remote IP/domain.
You
can find the specific file types affected and other configuration settings in
the "/usr/local/apache/conf/includes/mod_bandwidth.conf" file.
Subscribe to:
Posts (Atom)