Skip to main content

page speed

Better Performance Without Imagick PHP Extension

Est. reading time: 2 minutes

Quick Answer: Here are some ways to improve your Apache performance without relying on imagick at all: 1.

Here are some ways to improve your Apache performance without relying on imagick at all:

1. Enable mod_deflate or mod_brotli for Compression

  • utilize compression to reduce the size of assets sent to clients:
    apache
    # Enable Deflate for GZIP compression
    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json
    </IfModule>
    # Enable Brotli compression (if supported)
    <IfModule mod_brotli.c>
    AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css application/javascript application/json
    </IfModule>

2. Leverage mod_expires for Browser Caching

  • Set expiration headers to cache static assets in users’ browsers:
    apache
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType text/html "access plus 1 day"
    </IfModule>

3. utilize mod_headers for Caching and Security

  • Configure caching headers with mod_headers for enhanced control:
    apache
    <IfModule mod_headers.c>
    <FilesMatch ".(jpg|jpeg|png|gif|css|js)$">
    Header set Cache-Control "max-age=2592000, public"
    </FilesMatch>
    </IfModule>

4. Enable mod_http2 for HTTP/2

  • HTTP/2 can improve the speed of resource loading by allowing multiplexing, header compression, and prioritization.
  • To enable HTTP/2, make sure mod_http2 is enabled in your Apache configuration and then add:
    apache
    Protocols h2 http/1.1

5. Optimize the KeepAlive Directive

  • Enabling KeepAlive keeps the connection open for multiple requests, reducing latency for subsequent requests.
    apache
    KeepAlive On
    MaxKeepAliveRequests 100
    KeepAliveTimeout 5

6. Limit MaxRequestWorkers and ServerLimit

  • Adjust these directives in your Apache configuration (usually apache2.conf or httpd.conf) to optimize resource usage. The values depend on your server’s capacity.
    apache
    MaxRequestWorkers 150
    ServerLimit 150

7. utilize mod_cache for Caching

  • Apache’s caching modules (mod_cache, mod_cache_disk) can store frequently accessed files in cache for faster response times:
    apache
    <IfModule mod_cache.c>
    CacheQuickHandler off
    CacheLock on
    CacheIgnoreCacheControl On
    CacheDefaultExpire 3600
    CacheEnable disk /
    </IfModule>

8. Optimize Logging

  • Logging can impact performance, so set it to minimal or disable for assets if you don’t need detailed logs for them:
    apache
    LogLevel warn

These optimizations should assist improve your server’s performance by reducing resource usage and decreasing response times without requiring the imagick extension.

Need an SEO Expert? Get Your Free Strategy Session?