---
title: "Using PageSpeed Module to Speed Up Your Apache Web Server"
description: "Learn how to make your Apache Web Server even quicker with the Pagespeed Module in this ATA Learning tutorial!"
canonical: "https://adamtheautomator.com/pagespeed/"
---

# Using PageSpeed Module to Speed Up Your Apache Web Server

> Learn how to make your Apache Web Server even quicker with the Pagespeed Module in this ATA Learning tutorial!

Source: https://adamtheautomator.com/pagespeed/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Speed Up Your Apache Web Server with the Pagespeed Module](https://adamtheautomator.com/wp-content/uploads/2023/10/pagespeed.jpg)

# Speed Up Your Apache Web Server with the Pagespeed Module

[![](https://secure.gravatar.com/avatar/572a248f516b6d0cd566cb44fdbd9336f30ef95aa0f6d78f118c1f47b1b6d6b7?s=192&d=mm&r=g)Arvid Larson](https://adamtheautomator.com/author/arvid-larson/)24 October 20238 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Apache](/tag/apache/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Installing the PageSpeed Module](#installing-the-pagespeed-module)
*   [Configuring the PageSpeed Admin Page](#configuring-the-pagespeed-admin-page)
*   [Configuring PageSpeed Rewriting Levels and Filters](#configuring-pagespeed-rewriting-levels-and-filters)
*   [Integrating PageSpeed with External Cache via Memcached](#integrating-pagespeed-with-external-cache-via-memcached)
*   [Conclusion](#conclusion)

Does your web server feel like it is dragging its feet, especially when your traffic picks up? Well, you have come to the right place! The PageSpeed Module for Apache is the key to revving your web server.

By the end of this tutorial, you will have a powerful tool that will supercharge your server and have those pages loading faster than you can say “swiftly.”

Read on and turn your website into a speed demon!

## Prerequisites

Before you dive into the nitty-gritty of optimization, ensure you are all set up for this speed-boosting adventure:

*   A Linux server running Ubuntu 20.04/22.04 – This tutorial uses Ubuntu 22.04.

Related:[Install Ubuntu Server 20.04: A Step-by-Step Walkthrough](https://adamtheautomator.com/install-ubuntu/)

*   A user with sudo privileges.

Related:[How to Create Users on Ubuntu Linux in Multiple Ways](https://adamtheautomator.com/create-user-on-ubuntu/)

*   The [Apache](https://adamtheautomator.com/install-apache-on-ubuntu/) web server is installed on your Ubuntu server.

Related:[How to Install Apache on Ubuntu to Manage Your Traffic](https://adamtheautomator.com/install-apache-on-ubuntu/)

## Installing the PageSpeed Module

Picture this: your Apache web server, tirelessly churning out content to the world (a workhorse), but over time, your server can get bogged down. In such cases, this module is your server’s secret weapon against sluggish load times and unimpressed visitors.

The module you are about to install is an open-source web server module for optimizing and reducing the load times of your websites.

To install the module, carry out these steps:

1\. Open a terminal and run the below command to perform the following:

*   Provides information about the architecture of your system, displaying detailed CPU information ([`lscpu`](https://linuxhint.com/lscpu-command/)).
*   The output is then piped (`|`) to `grep Architecture`, which searches for lines containing the word `Architecture`.

Related:[Master Grep with Regex and Make Troubleshooting a Breeze](https://adamtheautomator.com/grep-with-regex/)

*   Extracts and prints the second field (which contains the actual architecture value) from the filtered output (awk {‘print $2’}).

```bash
lscpu | grep Architecture | awk {'print $2'}
```

The result below displays if you have a 64-bit system architecture.

Note the result, as it will be your basis for downloading the package.

![Checking system architecture](https://adamtheautomator.com/wp-content/uploads/2023/10/image-120.png)

Checking system architecture

2\. Next, run either `wget` command below to download it for Debian-based distribution.

```
# PageSpeed module for 64-bit architecture
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb

# PageSpeed module for 32-bit architecture
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.deb
```

Related:[PowerShell Wget: Download Files with Ease](https://adamtheautomator.com/powershell-download-file/)

If successful, the _**mod-pagespeed-stable\_current\_amd64.deb**_ file becomes available on your system.

![Downloading the PageSpeed module package for a Debian-based system](https://adamtheautomator.com/wp-content/uploads/2023/10/image-119.png)

Downloading the module package for a Debian-based system

3\. Once downloaded, run the [`dpkg`](https://www.educative.io/answers/what-is-the-linux-dpkg-command) command below to install the PageSpeed module package (`mod-pagespeed-stable_current_amd64.deb`) and its dependencies.

```bash
# Install the PageSpeed module package
sudo dpkg -i mod-pagespeed-stable_current_amd64.deb

# Resolve any dependencies or missing packages
sudo apt install -f
```

This supports Apache2 and NGINX web servers and 32-bit and 64-bit architectures. Thus, this module is a must-have for anyone serious about web performance.

![Installing the PageSpeed module ](https://adamtheautomator.com/wp-content/uploads/2023/10/image-118.png)

Installing the module

Related:[Learning Ubuntu Apt Get Through Examples](https://adamtheautomator.com/ubuntu-apt-get/)

4\. With the module installed, run the following commands to enable ([`a2enmod`](https://linuxcommandlibrary.com/man/a2enmod)) it to restart the `apache2` service, and apply the changes.

```bash
# Enable the PageSpeed module for Apache
sudo a2enmod pagespeed

# Restart the Apache web server to apply the changes
sudo systemctl restart apache2
```

Related:[Correct Way of Using Ubuntu systemctl to Control Systemd](https://adamtheautomator.com/ubuntu-systemctl/)

![Enabling the PageSpeed module and restarting the Apache2 service ](https://adamtheautomator.com/wp-content/uploads/2023/10/image-117.png)

Enabling the module and restarting the Apache2 service

> _💡 You can also disable the module when necessary with the following command:_
> 
> _`sudo a2dismod pagespeed`_

> _💡 Additionally, you can enable and disable it manually by modifying the configuration (/etc/apache2/mods-enabled/pagespeed.conf). You can enable the it with **ModPagespeed on** or disable it using **ModPagespeed off**._

![Enabling/Disabling the PageSpeed module via the configuration file](https://adamtheautomator.com/wp-content/uploads/2023/10/image-116.png)

Enabling/Disabling the module via the configuration file

5\. Lastly, run the `curl` command below to send a [HEAD request](https://reqbin.com/Article/HttpHead) (`-I`) to the specified URL. A HEAD request retrieves only the headers of the HTTP response without the actual content.

Ensure you replace `SERVER-IP` with your server’s IP address.

```bash
curl -I http://SERVER-IP/
```

Related:[CURL Linux Command : Learning By Example](https://adamtheautomator.com/curl-linux/)

The HTTP header **X-Mod-Pagespeed: 1.13.35.2-0** indicates that the PageSpeed installation is successful with the following breakdown:

*   The **X-Mod-Pagespeed** header is a custom HTTP header introduced by the module. When present, this header signifies that the module is active and functioning.
*   The version number **1.13.35.2-0** after **X-Mod-Pagespeed** verifies the installed PageSpeed module.
*   The HTTP status code of **200 OK** alongside the **X-Mod-Pagespeed** header indicates the request was successful, and the server responds with the requested content.

![Verifying the successful PageSpeed module installation](https://adamtheautomator.com/wp-content/uploads/2023/10/image-115.png)

Verifying the successful PageSpeed module installation

## Configuring the PageSpeed Admin Page

Kudos on getting the PageSpeed Module running. But still, you must ensure your Apache server is optimized for peak performance.

You will elevate control by configuring the [PageSpeed admin page](https://www.modpagespeed.com/doc/admin). PageSpeed provides an admin dashboard for monitoring the performance and logs and can also show PageSpeed configurations.

To configure the PageSpeed admin page, proceed with the following steps:

1\. Open PageSpeed’s configuration file (_/etc/apache2/mods-enabled/pagespeed.conf_) using your preferred text editor.

Related:[How to Get Started With Gedit Linux](https://adamtheautomator.com/gedit-linux/)

2\. Next, add the option **Allow from all** to both **<Location /pagespeed\_admin>…</Location>** and **<Location /pagespeed\_global\_admin>…</Location>** sections, as shown below.

Once added, save the changes and close the editor. This configuration makes the PageSpeed admin page accessible from anywhere.

![Making the PageSpeed admin page accessible from anywhere](https://adamtheautomator.com/wp-content/uploads/2023/10/image-122.png)

Making the PageSpeed admin page accessible from anywhere

> _💡 Alternatively, you can make the PageSpeed admin page accessible from a specific IP address. How? By changing the option `Allow from all` to `Allow from <IPADDRESS>`, replacing `<IPADDRESS>` with your preferred IP address._

3\. Now, run the `systemctl` command below to restart the `apache2` service and apply the changes.

```bash
sudo systemctl restart apache2
```

4\. Lastly, launch your web browser visit one of the following, replacing `*SERVER-IP*` with your server’s IP address:

<table><tbody><tr><th class="has-text-align-left" data-align="left">PageSpeed admin page</th><td><em>http://SERVER-IP/pagespeed_admin</em></td></tr><tr><th class="has-text-align-left" data-align="left">PageSpeed global admin page</th><td><em>http://SERVER-IP/pagespeed_global_admin</em></td></tr></tbody></table>

| Menu | Function |
| --- | --- |
| **Statistics** | Shows server statistics such as optimized resources, latency, and PageSpeed cache. |
| **Configuration** | Shows details of PageSpeed configuration, including enabled filters, additional options, and cache flush timestamp. |
| **Histograms** | Shows detailed information on load time pages, rewriting, caches, and HTTP fetching. |
| **Caches** | Displays details of cache configurations. |
| **Console** | Displays console graph of PageSpeed optimization over time. |
| **Message History** | Displays recent logs from PageSpeed. |
| **Graphs** | Allows you to view graphical representations of various performance metrics and statistics related to the PageSpeed module’s operation. |

![Accessing the PageSpeed admin page](https://adamtheautomator.com/wp-content/uploads/2023/10/image-121.png)

Accessing the PageSpeed admin page

## Configuring PageSpeed Rewriting Levels and Filters

With the PageSpeed admin page configured, enhancing your website’s speed and reducing latency is crucial. If you have ever wondered why some websites load faster than others, it is not magic but a result of advanced server-side optimizations.

You can dramatically boost your Apache server’s performance by configuring PageSpeed rewriting levels and [filters](https://www.modpagespeed.com/doc/filters). PageSpeed filters are like magic tricks for web pages; they work behind the scenes to make your website load snappier and smoother for visitors.

To configure, enable/disable PageSpeed filters to optimize your websites, follow these steps:

1\. Open the PageSpeed configuration (_/etc/apache2/mods-enabled/pagespeed.conf_), and add the following options. These options let you set up `Rewrite Level` via `CoreFilters` and disable and enable specific filters, as follows, that are safe for most websites:

*   `add_head` – Lets PageSpeed add necessary CSS and JavaScript code directly into the `<head>` section of your HTML. This filter helps speed up the initial loading of your page because the critical stuff gets priority access.  
    The decision to disable the `add_head` filter should be based on the specific requirements and circumstances of the website in question.
*   `lazyload_images` – This filter tells PageSpeed to load the images only when they are about to appear on the “stage” (to be seen by the user). This behavior saves bandwidth and makes your page load faster.
*   `move_css_to_head` – Instructs PageSpeed to take any CSS in the middle of your HTML and move it up to the `<head>` section. This way, the styles are ready before the page starts rendering, which helps display content more quickly and smoothly.

```
# Set up Rewrite Level using CoreFilters
ModPagespeedRewriteLevel CoreFilters

# Disable the add_head filter
ModPagespeedDisableFilters add_head

# Enable specific filters
ModPagespeedEnableFilters lazyload_images,move_css_to_head
```

Once added, save the file and exit the editor.

![Configuring Rewrite Level, disabling and enabling filters](https://adamtheautomator.com/wp-content/uploads/2023/10/image-124.png)

Configuring Rewrite Level, disabling and enabling filters

2\. Now, run the below `systemctl` command to restart the `apache2` service and apply the changes.

This command does not provide output, but you will verify the changes in the following step.

```bash
sudo systemctl restart apache2
```

3\. Lastly, switch back to the PageSpeed admin page and click the **Configuration** menu.

If the configuration is successful, you will see the list of enabled PageSpeed filters, including **Lazyload Images** and **Move Css To Head**. Plus, the default **RewriteLevel** is configured to **Core Filters**.

![Viewing the PageSpeed admin page configurations](https://adamtheautomator.com/wp-content/uploads/2023/10/image-123.png)

Viewing the PageSpeed admin page configurations

## Integrating PageSpeed with External Cache via Memcached

Having fine-tuned PageSpeed with rewriting levels and filters is excellent, but why not take the configurations up a notch? You need a powerful strategy for enhancing your website’s performance, scalability, and user experience — integrating PageSpeed with Memcached external cache.

You must configure the server-side caching for PageSpeed to get most of the PageSpeed module. The default cache method enabled by PageSpeed is file cache, but it also supports other caching methods, such as in-memory LRU cache and external cache via Memcached and Redis.

To integrate PageSpeed with external cache via Memcached, complete the steps below:

1\. Run the below `apt` command to `install` `memcached` to your Ubuntu system.

```bash
sudo apt install memcached -y
```

![Installing Memcached on Ubuntu](https://adamtheautomator.com/wp-content/uploads/2023/10/image-129.png)

Installing Memcached on Ubuntu

2\. Once installed, open the Memcached configuration (_/etc/memcached.conf_), increase the default memory option (`-m`) to **1024** MB, and change the default user (`-u`) to **www-data**.

After the changes, save the file and exit the editor.

![Modifying Memcached configurations](https://adamtheautomator.com/wp-content/uploads/2023/10/image-128.png)

Modifying Memcached configurations

3\. Next, run the `systemctl` command below to `restart` the `memcached` service.

This command does not produce output, but you will later see the result in the following steps.

```bash
sudo systemctl restart memcached
```

4\. Next, open the PageSpeed configuration (_/etc/apache2/mods-enabled/pagespeed.conf_) and modify the Memcached servers as follows:

*   Look for and uncomment the **ModPagespeedMemcachedServers** option by deleting the hash sign (**#**).
*   Change the **localhost** value to **127.0.0.1** to ensure consistent and reliable connections to the Memcached server.

This option enables Memcached integration and inputs the server IP address and port.

![](https://adamtheautomator.com/wp-content/uploads/2023/10/image-127.png)

5\. Now, run the below `systemctl` command to restart the `apache2` service.

```bash
sudo systemctl restart apache2
```

6\. Refresh the **Configuration** page within the PageSpeed admin page.

In the **MemcachedServers** section, you will see the memcached host **127.0.0.1** and port **11211**. This information is crucial for ensuring that PageSpeed is correctly configured to use Memcached as an external cache.

![Checking the memcached integration](https://adamtheautomator.com/wp-content/uploads/2023/10/image-126.png)

Checking the memcached integration

7\. Lastly, navigate to the **Caches** menu and click the **Physical Caches** sub-menu to view real-time insights into how Memcached is actively caching and serving content.

This information offers several benefits:

*   **Monitoring Performance** – Allows you to monitor how Memcached performs in real-time. You can see metrics like cache hits, misses, and evictions. This information helps in understanding how efficiently Memcached is improving website performance.
*   **Troubleshooting** – This view can provide valuable diagnostic information if there are any issues with Memcached. For example, a high rate of cache misses might indicate that certain resources are ineffective.
*   **Optimization** – Observing server activity lets you identify patterns and optimize caching strategies. For instance, you might discover opportunities to cache additional resources or adjust cache expiration times.
*   **Capacity Planning** – Understanding the activity in Memcached helps with capacity planning. If the cache is frequently reaching its limit, this behavior might indicate you need to allocate more resources or adjust cache configurations.
*   **Validation of Configuration** – Provides a visual confirmation that Memcached is actively working with the configurations you have set up. This view helps ensure that your caching setup is effectively integrated into your website’s performance strategy.

![Checking the memcached activity](https://adamtheautomator.com/wp-content/uploads/2023/10/image-125.png)

Checking the memcached activity

## Conclusion

Throughout this tutorial, you have embarked on a journey that transforms your Apache web server’s performance. You have armed your web server with a potent tool for rapid web experiences. This action includes installing the PageSpeed Module, configuring various settings like filters, and integrating PageSpeed seamlessly with an external cache via Memcached.

Now, why not consider diving deeper into Apache’s configuration options? Perhaps explore optimizing bandwidth usage with rewrite level [OptimizeForBandwidth](https://www.modpagespeed.com/doc/optimize-for-bandwidth) on PageSpeed? Or add new [filters](https://www.modpagespeed.com/doc/filters) and implement [PageSpeed on Apache virtual host](https://www.modpagespeed.com/doc/configuration#virtual-hosts) configurations?

Keep fine-tuning, experimenting, and pushing the boundaries of what your Apache web server can achieve!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpagespeed%2F&text=Speed%20Up%20Your%20Apache%20Web%20Server%20with%20the%20Pagespeed%20Module)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpagespeed%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpagespeed%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/04/How-to-Install-Apache-on-Ubuntu.jpg)

### [Install Apache on Ubuntu and Master Website Traffic Management](/install-apache-on-ubuntu/)

Ready to optimize your website for high traffic? Install Apache on Ubuntu with this step-by-step guide and ensure smooth performance under heavy loads.

![](https://adamtheautomator.com/wp-content/uploads/2024/02/apache-hadoop.jpg)

### [How to Install Apache Hadoop for Linux](/apache-hadoop/)

Unlock Apache Hadoop on Linux: Transform data handling with efficient, scalable processing and analysis in this ATA tutorial!

![](https://adamtheautomator.com/wp-content/uploads/2023/11/apache-spark.jpg)

### [How to Install Apache Spark for Windows](/apache-spark/)

Learn how to process and transform large datasets on Windows with Apache Spark in this in-depth ATA Learning tutorial!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
