• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

NGINX does not GZIP scripts with version parameters

Xavier1234

New Pleskian
Hi,

I'm using latest plesk with ubuntu 12.04, apache and nginx, gzip is enabled and working fine, except for JS and CSS files wich have version parameters in the URI, for example :
http://domain.com/wp-content/plugins/sitepress-multilingual-cms/res/css/language-selector.css?v=3.1.9.7

here is my conf in /etc/nginx/conf.d/gzip.conf :
Code:
gzip         on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_types   text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary    on;

Gzip is working fine for every other ressources loaded
I know i can strip these ?ver= using PHP, but if nginx could just enqueue them properly as they are, i would be the happiest man, thank you!

Thank you
 
Hi Xavier1234,

how do you check, if "...v=3.1.9.7" is being compressed or not? As a matter of fact, the additional string should not be a reason for nginx to not compress such files. Please make sure, that apache AND nginx have the same corresponding gzip - settings.
 
Hi Xavier1234,

how do you check, if "...v=3.1.9.7" is being compressed or not?
Hello and thank you, i check using http://gtmetrix.com/ gtmetrics tells me that all files ending with a parameter ?v=x.x.x or ?ver=x.x.x are not compressed, if i strip the parameter using php, they end up being compressed
Please make sure, that apache AND nginx have the same corresponding gzip - settings.
Apache:
Code:
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
    SetEnvIfNoCase Request_URI \.(?:rar|zip)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.(?:gif|jpg|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.(?:avi|mov|mp4)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary
</IfModule>
and
here is my conf in /etc/nginx/conf.d/gzip.conf :
Code:
gzip         on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_types   text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary    on;
 
Hi Xavier1234,

if you use wordpress, you might wish to use the additional code in your theme - specific - functions.php:

Code:
        function _remove_script_version( $src ){
            $parts = explode( '?', $src );
            return $parts[0];
        }
        add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
        add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
 
Back
Top