Asset Version

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Asset Version

Post by david63 »

When you add a .css or .js file from an extension there is appended to it asset_version=xxx

As far as I can see the asset_version is derived from the config variable asset_version

The question is - what is its purpose and what does it do?
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
kasimi
Former Team Member
Posts: 4900
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Asset Version

Post by kasimi »

For caching reasons, mostly: https://developers.google.com/web/funda ... -responses

Clearing the board cache increases the asset_version and thus forces the client to download a fresh copy of all assets.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Asset Version

Post by david63 »

That sort of makes sense - but if you clear the cache then you would get a new version anyway, with or without the asset_version
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 28619
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Asset Version

Post by Paul »

No, the phpBB cache is not related to the browser cache ;)
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Asset Version

Post by david63 »

Sorry - I had missed the browser cache bit.

This does beg the question though - why are not all .css and .js files treated in the same way? Most of the core .css files do not use asset_version (or is this a "work in progress"?)
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
kasimi
Former Team Member
Posts: 4900
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Asset Version

Post by kasimi »

david63 wrote:Most of the core .css files do not use asset_version
In 3.1.9 they do:

CSS

Code: Select all

<link href="./styles/prosilver/theme/stylesheet.css?assets_version=123" rel="stylesheet">
<link href="./styles/prosilver/theme/en/stylesheet.css?assets_version=123" rel="stylesheet">
<link href="./styles/prosilver/theme/responsive.css?assets_version=123" rel="stylesheet" media="all and (max-width: 700px)">
JS

Code: Select all

<script type="text/javascript" src="./styles/prosilver/template/forum_fn.js?assets_version=123"></script>
<script type="text/javascript" src="./styles/prosilver/template/ajax.js?assets_version=123"></script>
The only asset I found without a version attached to it is

Code: Select all

<script type="text/javascript" src="./assets/javascript/editor.js"></script>
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Asset Version

Post by david63 »

But not on this site

Code: Select all

<link href="/community/styles/prosilver/theme/print.css" rel="stylesheet" type="text/css" media="print" title="printonly" />
<link href="/community/styles/prosilver/theme/stylesheet.css" rel="stylesheet" type="text/css" media="screen, projection" />
<link href="./styles/prosilver/theme/responsive.css?2014081401" rel="stylesheet" type="text/css" media="only screen and (max-width: 700px), only screen and (max-device-width: 700px)" />
<link href="/assets/css/index.css?2015010500" rel="stylesheet" type="text/css" media="screen, projection" />
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
MakisH
Registered User
Posts: 47
Joined: Fri Sep 24, 2010 6:18 pm

Re: Asset Version

Post by MakisH »

I ran a speedtest on my forum and it mainly complains about this:
Remove query strings from static resources
Resources with a "?" in the URL are not cached by some proxy caching servers. Remove the query string and encode the parameters into the URL for the following resources:
In the list I see several resources, including many that I personally don't plan to edit (like the core.js). Is it safe to remove the assets_version part from the resources that probably will never be changed from me?

What are the problems? What happens e.g. in a total phpBB upgrade?
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5859
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman

Re: Asset Version

Post by MattF »

No, do not change them. You may not plan to edit any files, but whenever you update your board (or an extension) the files can be new, and those cache busters are in place so your users don't have a bad experience by loading your board with outdated stale components.

You should ignore those so-called speed test recommendations. It won't speed anything up, and those recommendations are aimed at developers who have created their own unique site content, and not really to those using 3rd party web applications such as phpBB (or wordpress or drupal or joomla, etc).
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
MakisH
Registered User
Posts: 47
Joined: Fri Sep 24, 2010 6:18 pm

Re: Asset Version

Post by MakisH »

Thank you, I will probably follow your advice, but I would like some more discussion or this.

1. So what about the statement "Resources with a "?" in the URL are not cached by some proxy caching servers."? I couldn't really find any explicit/clear statement about this anywhere else.

2. If the [1] holds, wouldn't it be better to gather all these core dependencies in a directory like assets/phpBB_3.1.9/ and change the directory during each upgrade? If [1] holds, I find it too much using the current approach e.g. for core or for standard non-phpBB libraries (scripts). For styles and extensions I understand it, since many users customize them.

3. Maybe it will not speed anything up, although that's something that I could experiment with. But why do you say that? Based on what and for which cases?

Sorry if I push too much, I believe you in principle but I also want to understand and learn! :-)

edit: Interestingly enought:
1. The same recommendation is given when I test StackOverflow or GitHub.
2. When I try e.g. a phpbb.com viewforum page it doesn't complain, although it uses ?assets_version= in inclusions. Maybe because it reports "more severe" problems before this, although it passes the "Remove query strings from static resources" test.
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5859
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman

Re: Asset Version

Post by MattF »

MakisH wrote:1. So what about the statement "Resources with a "?" in the URL are not cached by some proxy caching servers."? I couldn't really find any explicit/clear statement about this anywhere else.
That refers to people that use a proxy. Such as people trying to hide their identity/IP address. Are you planning to attract the Russian mob to your site? 8-) In some cases it may apply to cloud caching (CDN) services, but the reputable ones such as cloudflare, this isn't a problem, and if you're not using one of those services, again this is of no consequence. The key there in the warning is "some".
MakisH wrote: 3. Maybe it will not speed anything up, although that's something that I could experiment with. But why do you say that? Based on what and for which cases?
Because the warning has nothing to do with page speed, but just with the possibility that cache busting potentially might not be of any use to "some" people visiting your site through a "some" proxy service (if they even do at all).

phpBB uses cache busting because it is a proven and standard technique for all well made web applications to ensure current (non-stale) assets are served. Because phpBB can't know or control how your server is set up, it relies on this technique.
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
MakisH
Registered User
Posts: 47
Joined: Fri Sep 24, 2010 6:18 pm

Re: Asset Version

Post by MakisH »

I am happy with this answer! :D Thank you also for the reference!
Lon2
Registered User
Posts: 66
Joined: Fri Sep 25, 2015 5:37 pm

Re: Asset Version

Post by Lon2 »

Is there a way to temporarily add forum images (topic icons) to Asset Version?
Post Reply

Return to “Extension Writers Discussion”