Hypertext Access file

Speed Optimization

Enable Compression (Apache 2.0+)

Enabling gzip compression can reduce the size of the transferred response by up to 90%, which can significantly reduce the amount of time to download the resource, reduce data usage for the client, and improve the time to first render of your pages. — PageSpeed Insights

Compression can be enabled with this:

AddOutputFilterByType DEFLATE "text/html"/
                              "text/plain"/
                              "text/xml"/
                              "text/css"/
                              "text/javascript"/
                              "application/javascript"

Apache Docs

Leverage Browser Caching (Apache 2.0+)

Fetching resources over the network is both slow and expensive: the download may require multiple roundtrips between the client and server, which delays processing and may block rendering of page content, and also incurs data costs for the visitor. All server responses should specify a caching policy to help the client determine if and when it can reuse a previously fetched response. — PageSpeed Insights

You can leverage browser caching like this:

# Enable browser caching
ExpiresActive On

# Set the default caching duration
ExpiresDefault "access plus 1 week"

# Change the caching duration by file type
ExpiresByType text/html "access plus 2 weeks"

Apache Docs

Enable KeepAlive (Apache 2.0+)

The Keep-Alive extension to HTTP/1.0 and the persistent connection feature of HTTP/1.1 provide long-lived HTTP sessions which allow multiple requests to be sent over the same TCP connection. In some cases this has been shown to result in an almost 50% speedup in latency times for HTML documents with many images. To enable Keep-Alive connections, set KeepAlive On. — Apache Docs

# Enable KeepAlive
KeepAlive On

# OPTIONAL — limit the amount of requests per connection with 'MaxKeepAliveRequests'
# Example: MaxKeepAliveRequests 500

# OPTIONAL — limit the amount of time the server will wait before it closes 
# the connection with 'KeepAliveTimeout'
# Example: KeepAliveTimeout 500

Apache Docs


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow