Browser Cache Expires & GZIP Compression Enable

GZIP is a file format that allows for a file to be compressed to produce a smaller file size. This is a good tool for reducing the size of large files, like video or graphics files. GZIP compression will typically reduce the size of a file by about 10% for each level of compression.

A GZIP compression is a file-format that allows for a file to be compressed to produce a smaller file size.

Browser Cache and GZIP compression can speed up your website in many ways. To apply browser cache and GZIP compression, just copy the following code and paste it inside your function.php file.

					/** Browser Cache Expires & GZIP Compression **/
register_activation_hook(__FILE__, 'jltwp_adminify_htaccess');

/** Browser Cache Expires & GZIP Compression **/
function jltwp_adminify_htaccess()
    // We get the main WordPress .htaccess filepath.
    $ruta_htaccess = get_home_path() . '.htaccess'; // !

    $lineas = array();
    $lineas[] = '<IfModule mod_expires.c>';
    $lineas[] = '# Activar caducidad de contenido';
    $lineas[] = 'ExpiresActive On';
    $lineas[] = '# Directiva de caducidad por defecto';
    $lineas[] = 'ExpiresDefault "access plus 1 month"';
    $lineas[] = '# Para el favicon';
    $lineas[] = 'ExpiresByType image/x-icon "access plus 1 year"';
    $lineas[] = '# Imagenes';
    $lineas[] = 'ExpiresByType image/gif "access plus 1 month"';
    $lineas[] = 'ExpiresByType image/png "access plus 1 month"';
    $lineas[] = 'ExpiresByType image/jpg "access plus 1 month"';
    $lineas[] = 'ExpiresByType image/jpeg "access plus 1 month"';
    $lineas[] = '# CSS';
    $lineas[] = 'ExpiresByType text/css "access 1 month"';
    $lineas[] = '# Javascript';
    $lineas[] = 'ExpiresByType application/javascript "access plus 1 year"';
    $lineas[] = '</IfModule>';
    $lineas[] = '<IfModule mod_deflate.c>';
    $lineas[] = '# Activar compresión de contenidos estáticos';
    $lineas[] = 'AddOutputFilterByType DEFLATE text/plain text/html';
    $lineas[] = 'AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/xml-dtd';
    $lineas[] = 'AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml image/svg+xml';
    $lineas[] = 'AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript';
    $lineas[] = 'AddOutputFilterByType DEFLATE font/otf font/opentype application/font-otf application/x-font-otf';
    $lineas[] = 'AddOutputFilterByType DEFLATE font/ttf font/truetype application/font-ttf application/x-font-ttf';
    $lineas[] = '</IfModule>';

    insert_with_markers($ruta_htaccess, 'WP Adminify by Jewel Theme', $lineas); // !

WP Adminify Cache & GZIP Compression

Instead of coding you can enable cache & GZIP using WP Adminify plugin too. After installation navigate to WP Adminify > Tweaks > Performance. Now search for “Cache & GZIP Compressions“, enable the switcher and save your settings. That’s how to enable browser cache and GZIP compressions using WP Adminify.

cache and GZIP compressions
August 28, 2021
Was this article helpful?

© 2021 - Adminify | All rights reserved

WP Adminfy accepted payment methods