Retrieve the assets filename


#1

Hello all,

I would want to know is there any solution to retrieve the random versioning number for asset files?
Have tried to grep the /var/discourse folder but no luck in finding similar files. Any idea how to do so?


(Rafael dos Santos Silva) #2

JS is inside /var/www/discourse/public/assets and CSS in /var/www/discourse/tmp/stylesheet-cache


#3

Is it possible to turn off the cache versioning? As I am having difficulty to directly read filenames from nginx :facepalm:

Otherwise I will have to manually input the versioning if there is any changes, and that’s a pain in the ass.


(Rafael dos Santos Silva) #4

You dont wan’t that. They have a max-age of 1 year, that would break a lot of stuff.

Can you explain what nginx shenanigans you are doing that you don’t just proxy everything to Discourse docker port?


#5

Mmm, right. So I’m doing some HTTP/2 server push configuration, and wonder if I could server push all the asset files in a single header. However turns out the versioning cache files are in the container, and without disabling the versioning, nginx can’t have the header set statically.

The current configuration is:
End client <==> Cloudflare <==> My server's nginx <-=-socket-=-> Discourse docker

Which eventually the max-age and other stuff will be overwritten by Cloudflare anyway(either manually clearing cache or automatically by configurable duration), so I think it would be better to push all the asset in first request, then users can utilize their local cache (hoping) to accelerate the page load.


(Rafael dos Santos Silva) #6

This would be better done in core / plugin.

Problem being that Nginx still doesn’t support it.

If you really want to add support for push, you can try to craft a plugin that makes rails add the needed Link Headers and test on yor setup if it goes well.

When/if nginx uses the same (and recomended) behavior for server push as Cloudfare that can be incorporated into core.


(Kane York) #7

Note that push isn’t worth it if you can’t push out the HTML within the bandwidth-delay product, or if you can’t start pushing an asset before the browser would have made the request for it.

So the primary candidates for push are resources added from .js files or referenced from .CSS files if the HTML is large. And even then, link rel=preload may be just as good.