RISE adds a version to the end of every CSS and JavaScript file it loads, like app.all.css?v=4.2.1763800000. The version is the app version plus the time the file was last changed. When a file changes, its link changes too, so browsers load the new file right away.
This lets you cache CSS, JavaScript and font files for a long time on your server (for example one year), without visitors getting old files after an update.
Load your plugin files
Use load_css() and load_js(). They add the version for you:
load_css(array(
"plugins/My_Plugin/assets/css/my_plugin.css"
));
load_js(array(
"plugins/My_Plugin/assets/js/my_plugin.js"
));
Write the link yourself
If you write the <link> or [removed] tag yourself, use get_asset_version() with the same path:
$path = "plugins/My_Plugin/assets/js/my_plugin.js"; echo "[removed][removed]";
The path starts from the RISE folder. If the file is not found, only the app version is used.
Do not use a fixed version like ?v=1.0. Its link never changes, so it can't be cached for long, and after a plugin update visitors may see the old file for a while.
Server caching
Pages are never cached. Only files whose ?v= ends with a file time should get a long cache time. Other files (no version, or a fixed version like ?v=1.0) should get a short one. Example for nginx:
map $arg_v $asset_cache_control {
"~^[0-9.]*\.[0-9]{9,}$" "public, max-age=31536000, immutable";
default "max-age=3600";
}
server {
location ~* \.(css|js|woff2?|png|jpg|svg)$ {
add_header Cache-Control $asset_cache_control;
try_files $uri /index.php?$query_string;
}
}