Last updated on September 18th, 2025 at 06:08 am
Apache web server is popularly used by many websites, applications and blogs. It supports high traffic and extreme server loads. However, sometimes your Apache server may slow down due to various reasons. In such cases, you will need to either upgrade your server hardware or use a cheaper solution such as optimizing its performance. In this article, we will learn how to speed up Apache web server.
How to Speed Up Apache Web Server
There are several ways to optimize your Apache web server.
1. Optimizing Configuration
In this approach, we fine tune the Apache configuration file to improve its performance.
Disable Unnecessary Modules
Every Apache Server uses many different modules to extend its functionality and support more features. But every time your server loads, it has to load all these modules, thereby making it slower.
Over time, system administrators keep adding more and more modules without removing any of the existing ones. There may be modules that you do not need or have become outdated. So it is useful to identify and remove such Apache modules from your server installation.
For Ubuntu/Debian systems, go to /etc/apache2/mods-enabled/ to get a list of installed modules. You can remove specific modules using ‘sudo a2mod <module_name>‘ command. For Redhat/Fedora systems, open the .conf file located in /etc/httpd/conf.d/ directory. You can disable a module by adding # at the beginning of the LoadModule directive that loads the module.
Minimize .htaccess Use
.htaccess is a very convenient file that allows you to configure Apache server without accessing its server configuration file. But it can add significant overhead if not used properly. Web developers and system administrators keep adding more and URL redirection and rewrite rules in .htaccess file. These rules are loaded into Apache every time your server starts. Each redirect and rewrite only slows down your website, and must be avoided as far as possible. Also it is advisable to maintain as few .htaccess files as possible since Apache needs to separately load each .htaccess file.
Use KeepAlive
When Apache server’s KeepAlive directive is enabled, then it will use a single TCP connection between client and server to send multiple requests, instead of creating a new connection for every request. This is very useful in reducing server bandwidth and allows Apache server to accept requests from more clients.
Also, since the same TCP connection is used to send multiple requests, it avoids the need to establish a separate handshake for every request. This improves server performance. Therefore, you must set KeepAlive directive value to On in Apache server. You set it by adding the following line to your server configuration file.
KeepAlive on;
Similarly, you can also use KeepAliveTimeout directive to set the number of seconds Apache should wait before it terminates the connection.
Use MaxRequestWorkers
Apache’s MaxRequestWorkers directive allows you to define the maximum number of requests your Apache server is allowed to process. This is a vey useful parameter to optimize server performance. If you set it to a large value, then it will consume a lot of resources. In older Apache versions, you need to use MaxClients directive.
Choose the Right MPM
Apache features multi-processing modules (MPMs) such as prefork, worker, event for parallel processing. It allows Apache server to process more requests with less memory consumption, thereby improving its performance. Among them, event and worker MPMs are efficient since they support threading. Therefore, you should your server MPM preferences to event/worker. Here is an example to set mpm worker to event configuration using a2enmod utility.
sudo a2enmod mpm_event
2. Use Caching
Caching and Compression speed up Apache server performance greatly. Therefore, every system administrator must definitely enable and fine tune them to speed up Apache server. The main objective of caching is to reduce the number of requests actually served by your server by saving frequently or recently requested items elsewhere.
Use Caching Modules
Apache provides mod_cache module that allows you to cache frequently as well as recently access content on Apache server. It also supports mod_disk_cache and mod_mem_cache to cache using disk and memory respectively.
Apache also features mod_deflate and mod_gzip to compress the content before sending it to the client. This compressed client is automatically decompressed by client browser. Compressing response data before sending it, saves data bandwidth, improves page load speed and performance. These modules even allow you to compress specific data types such as images, css, js, and html files.
Enable Browser Caching
You can even configure Apache server to instruct client web browsers to cache responses. This will allow it to directly load frequently accessed content directly from web browser instead of requesting it from server. This will reduce server load a lot. You can do this by enabling mod_expires module as shown below.
sudo a2enmod expires
Use Content Delivery Network (CDN)
Content Delivery Network (CDN) is a very useful method to speed up Apache server and bring down its server load. It works by hosting most of your static content such as images, files, videos, etc. on a third-party server. When a user loads your web page, the requests for these static content is sent directly to the CDN vendor and not your server. These static files are directly received from the CDN to client web browser. This considerably reduces your web server load.
CDNs are very useful for content-heavy websites like streaming sites, social media networks and software download sites. They are commonly used by global organizations like Microsoft and Amazon. But they can also be used by SMEs.
Use PHP Accelerators
If your website or application uses PHP pages, then you can use PHP accelerators like OPcache to pre-compile PHP code and speed up its execution.
3. Optimizing Content
In most websites, transfer of content from web server to client browser takes up bulk of processing and network bandwidth. If you can optimize this part, it will significantly improve server performance.
Optimize Images
Most websites, blogs and apps use images to improve user experience. But images take up a lot of space on disk as well as network bandwidth. So it is better use compressed image formats such as JPEG, PNG, WebP, GIF, and HEIF. Using this in combination with enabling gzip will increase web server performance a lot.
Lazy Loading
There is no need to load all images on a page when the page is loaded. Instead, you can use lazy loading technique to load only those images that are visible in user’s viewport. This is commonly used in social media feeds and timelines. This reduces the number of requests sent to your server and improves its performance.
Reduce HTTP Requests
Every HTTP request involves certain overhead with regards to connection establishment. You can speed up your web pages by reducing the number of requests sent from your web page to your server. This can be done by combining CSS and JS files.
Index Databases
Most websites and apps need to query databases to fetch data and populate web pages. These queries can be time consuming if they are complex of if your database is really large. So you can speed up your database queries by indexing databases. This will speed up database queries, and in turn requests.
4. Server Environment
It is important to keep your server environment up to date, to get the best performance for your website.
Update Apache Software
Often system administrators run the same old Apache installation for years without updating it. Apache server is regularly updated with performance improvements, new features and security updates. You may realize that some of the new features offer completely new and faster ways of performing a task, thereby speeding up your server. So it is important to regularly update your Apache server installation.
Upgrade CPU & RAM
If your website is growing fast, then pretty soon, these optimizations will hit a limit. If possible, you should look into upgrading your CPU and RAM to improve server performance.
5. Monitoring & Analysis
Monitor Server Performance
You must regularly monitor your Apache server’s performance to make sure its resources (CPU, RAM, I/O, etc.) are working properly. For this purpose, you can install mod_status Apache module. It provides a real-time reporting dashboard to track all the key server metrics. Here is our detailed tutorial about how to install & enable mod_status in Apache server.
Conclusion
In this article, we have learnt several simple and effective ways to optimize and speed up Apache web server. There is no one-size-fits-all or a single solution to improve server performance. You will need to try them one by one, to see what works best for you. Ensure that you implement the above tips only one after the other so that in case something goes wrong, you can quickly identify and roll back the most recent changes. No matter how powerful your server hardware, you will need to invariably optimize your server to get the best performance, at some point or the other. So better start now before its too late.
Also read:
Apache Deny Access to URL, Files & Directory
How to Enable Server Side Includes (SSI)
How to Disable ETags in Apache Server

Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI & software development.