plugin-icon

Resource Versioning

Viktor Szépe yazdı·
Turn Query String Parameters into file revision numbers.
Oylama
5/5
Sürüm
0.3.0
Aktif kurulumlar
10
Son güncellenme
Jul 21, 2018
Resource Versioning

“It’s important to make resources (images, scripts, stylesheets, etc.) cacheable.”

Steve Souders

It is much easier to use a CDN without Query String Parameters. This plugins alters only local resources’ URL-s. The ver Query String Parameter will be inserted into the filename.

For example jquery.min.js?ver=1.10 becomes jquery.min.110.js.

To reverse this in the web server add this line to your nginx config:

server { location ~ ^(.+)\.\d\d+\.(js|css|png|jpg|jpeg|gif|ico)$ { #try_files $uri $1.$2 /index.php?$args; try_files $uri $1.$2 =404; } }

Or to your Apache configuration or .htaccess file.

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)\.\d\d+\.(js|css|png|jpg|jpeg|gif|ico)$ $1.$2 [NC,L]

Testing the plugin before live usage

You can test the plugin by replacing the two add_filter() calls with this

require_once( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/wp-load.php' ); wp(); echo o1_revving_src( $argv[1] ) . PHP_EOL;

Then start it from CLI: php revving.php <TEST-URL>

Links

Development of this plugin goes on on GitHub.

ÜcretsizBusiness paketinde
Kurulum işlemini tamamlayarak, WordPress.com'un Hizmet Şartları ile Üçüncü Taraf Eklenti Şartlarını kabul etmiş olursunuz.
Test edilen son sürüm
WordPress 4.9.28
Bu eklenti, sitenizde kullanılmak üzere indirilebilir.