Use separate asset version for cache busting

This commit is contained in:
Omar Roth 2019-05-09 11:52:37 -05:00
parent bfa488f77d
commit fd8af88493
No known key found for this signature in database
GPG key ID: B8254FB7EC3D37F2
8 changed files with 59 additions and 54 deletions

View file

@ -53,6 +53,11 @@ CURRENT_BRANCH = {{ "#{`git branch | sed -n '/\* /s///p'`.strip}" }}
CURRENT_COMMIT = {{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit`.strip}" }} CURRENT_COMMIT = {{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit`.strip}" }}
CURRENT_VERSION = {{ "#{`git describe --tags --abbrev=0`.strip}" }} CURRENT_VERSION = {{ "#{`git describe --tags --abbrev=0`.strip}" }}
# This is used to determine the `?v=` on the end of file URLs (for cache busting). We
# only need to expire modified assets, so we can use this to find the last commit that changes
# any assets
ASSET_COMMIT = {{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit -- assets`.strip}" }}
SOFTWARE = { SOFTWARE = {
"name" => "invidious", "name" => "invidious",
"version" => "#{CURRENT_VERSION}-#{CURRENT_COMMIT}", "version" => "#{CURRENT_VERSION}-#{CURRENT_COMMIT}",
@ -1854,12 +1859,12 @@ post "/data_control" do |env|
sleep 20.seconds sleep 20.seconds
env.response.puts %(<meta http-equiv="refresh" content="0; url=#{referer}">) env.response.puts %(<meta http-equiv="refresh" content="0; url=#{referer}">)
env.response.puts %(<link rel="stylesheet" href="/css/ionicons.min.css?v=<%= CURRENT_COMMIT %>">) env.response.puts %(<link rel="stylesheet" href="/css/ionicons.min.css?v=#{ASSET_COMMIT}">)
env.response.puts %(<link rel="stylesheet" href="/css/default.css?v=<%= CURRENT_COMMIT %>">) env.response.puts %(<link rel="stylesheet" href="/css/default.css?v=#{ASSET_COMMIT}">)
if env.get("preferences").as(Preferences).dark_mode if env.get("preferences").as(Preferences).dark_mode
env.response.puts %(<link rel="stylesheet" href="/css/darktheme.css?v=<%= CURRENT_COMMIT %>">) env.response.puts %(<link rel="stylesheet" href="/css/darktheme.css?v=#{ASSET_COMMIT}">)
else else
env.response.puts %(<link rel="stylesheet" href="/css/lighttheme.css?v=<%= CURRENT_COMMIT %>">) env.response.puts %(<link rel="stylesheet" href="/css/lighttheme.css?v=#{ASSET_COMMIT}">)
end end
env.response.puts %(<h3><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>) env.response.puts %(<h3><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>)
env.response.flush env.response.flush

View file

@ -47,4 +47,4 @@ var player_data = {
thumbnail: "<%= thumbnail %>" thumbnail: "<%= thumbnail %>"
} }
</script> </script>
<script src="/js/player.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/player.js?v=<%= ASSET_COMMIT %>"></script>

View file

@ -1,22 +1,22 @@
<link rel="stylesheet" href="/css/video-js.min.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/video-js.min.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/videojs-http-source-selector.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/videojs-http-source-selector.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/videojs.markers.min.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/videojs.markers.min.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/videojs-share.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/videojs-share.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/videojs-vtt-thumbnails.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/videojs-vtt-thumbnails.css?v=<%= ASSET_COMMIT %>">
<script src="/js/video.min.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/video.min.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/videojs-contrib-quality-levels.min.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/videojs-contrib-quality-levels.min.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/videojs-http-source-selector.min.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/videojs-http-source-selector.min.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/videojs.hotkeys.min.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/videojs.hotkeys.min.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/videojs-markers.min.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/videojs-markers.min.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/videojs-share.min.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/videojs-share.min.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/videojs-vtt-thumbnails.min.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/videojs-vtt-thumbnails.min.js?v=<%= ASSET_COMMIT %>"></script>
<% if params.annotations %> <% if params.annotations %>
<link rel="stylesheet" href="/css/videojs-youtube-annotations.min.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/videojs-youtube-annotations.min.css?v=<%= ASSET_COMMIT %>">
<script src="/js/videojs-youtube-annotations.min.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/videojs-youtube-annotations.min.js?v=<%= ASSET_COMMIT %>"></script>
<% end %> <% end %>
<% if params.listen || params.quality != "dash" %> <% if params.listen || params.quality != "dash" %>
<link rel="stylesheet" href="/css/quality-selector.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/quality-selector.css?v=<%= ASSET_COMMIT %>">
<script src="/js/silvermine-videojs-quality-selector.min.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/silvermine-videojs-quality-selector.min.js?v=<%= ASSET_COMMIT %>"></script>
<% end %> <% end %>

View file

@ -29,7 +29,7 @@
unsubscribe_text: '<%= HTML.escape(translate(locale, "Unsubscribe")) %>' unsubscribe_text: '<%= HTML.escape(translate(locale, "Unsubscribe")) %>'
} }
</script> </script>
<script src="/js/subscribe_widget.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/subscribe_widget.js?v=<%= ASSET_COMMIT %>"></script>
<% else %> <% else %>
<p> <p>
<a id="subscribe" class="pure-button pure-button-primary" <a id="subscribe" class="pure-button pure-button-primary"

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="thumbnail" content="<%= thumbnail %>"> <meta name="thumbnail" content="<%= thumbnail %>">
<%= rendered "components/player_sources" %> <%= rendered "components/player_sources" %>
<link rel="stylesheet" href="/css/default.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/default.css?v=<%= ASSET_COMMIT %>">
<title><%= HTML.escape(video.title) %> - Invidious</title> <title><%= HTML.escape(video.title) %> - Invidious</title>
<style> <style>
#player { #player {
@ -35,6 +35,6 @@ var video_data = {
</script> </script>
<%= rendered "components/player" %> <%= rendered "components/player" %>
<script src="/js/embed.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/embed.js?v=<%= ASSET_COMMIT %>"></script>
</body> </body>
</html> </html>

View file

@ -11,7 +11,7 @@
<table id="jslicense-labels1"> <table id="jslicense-labels1">
<tr> <tr>
<td> <td>
<a href="/js/embed.js?v=<%= CURRENT_COMMIT %>">embed.js</a> <a href="/js/embed.js?v=<%= ASSET_COMMIT %>">embed.js</a>
</td> </td>
<td> <td>
@ -19,13 +19,13 @@
</td> </td>
<td> <td>
<a href="/js/embed.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a> <a href="/js/embed.js?v=<%= ASSET_COMMIT %>"><%= translate(locale, "source") %></a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<a href="/js/player.js?v=<%= CURRENT_COMMIT %>">player.js</a> <a href="/js/player.js?v=<%= ASSET_COMMIT %>">player.js</a>
</td> </td>
<td> <td>
@ -33,13 +33,13 @@
</td> </td>
<td> <td>
<a href="/js/player.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a> <a href="/js/player.js?v=<%= ASSET_COMMIT %>"><%= translate(locale, "source") %></a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<a href="/js/silvermine-videojs-quality-selector.min.js?v=<%= CURRENT_COMMIT %>">silvermine-videojs-quality-selector.min.js</a> <a href="/js/silvermine-videojs-quality-selector.min.js?v=<%= ASSET_COMMIT %>">silvermine-videojs-quality-selector.min.js</a>
</td> </td>
<td> <td>
@ -53,7 +53,7 @@
<tr> <tr>
<td> <td>
<a href="/js/subscribe_widget.js?v=<%= CURRENT_COMMIT %>">subscribe_widget.js</a> <a href="/js/subscribe_widget.js?v=<%= ASSET_COMMIT %>">subscribe_widget.js</a>
</td> </td>
<td> <td>
@ -61,13 +61,13 @@
</td> </td>
<td> <td>
<a href="/js/subscribe_widget.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a> <a href="/js/subscribe_widget.js?v=<%= ASSET_COMMIT %>"><%= translate(locale, "source") %></a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<a href="/js/videojs-contrib-quality-levels.min.js?v=<%= CURRENT_COMMIT %>">videojs-contrib-quality-levels.min.js</a> <a href="/js/videojs-contrib-quality-levels.min.js?v=<%= ASSET_COMMIT %>">videojs-contrib-quality-levels.min.js</a>
</td> </td>
<td> <td>
@ -81,7 +81,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs.hotkeys.min.js?v=<%= CURRENT_COMMIT %>">videojs.hotkeys.min.js</a> <a href="/js/videojs.hotkeys.min.js?v=<%= ASSET_COMMIT %>">videojs.hotkeys.min.js</a>
</td> </td>
<td> <td>
@ -95,7 +95,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs-http-source-selector.min.js?v=<%= CURRENT_COMMIT %>">videojs-http-source-selector.min.js</a> <a href="/js/videojs-http-source-selector.min.js?v=<%= ASSET_COMMIT %>">videojs-http-source-selector.min.js</a>
</td> </td>
<td> <td>
@ -109,7 +109,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs-markers.min.js?v=<%= CURRENT_COMMIT %>">videojs-markers.min.js</a> <a href="/js/videojs-markers.min.js?v=<%= ASSET_COMMIT %>">videojs-markers.min.js</a>
</td> </td>
<td> <td>
@ -123,7 +123,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs-share.min.js?v=<%= CURRENT_COMMIT %>">videojs-share.min.js</a> <a href="/js/videojs-share.min.js?v=<%= ASSET_COMMIT %>">videojs-share.min.js</a>
</td> </td>
<td> <td>
@ -137,7 +137,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs-vtt-thumbnails.min.js?v=<%= CURRENT_COMMIT %>">videojs-vtt-thumbnails.min.js</a> <a href="/js/videojs-vtt-thumbnails.min.js?v=<%= ASSET_COMMIT %>">videojs-vtt-thumbnails.min.js</a>
</td> </td>
<td> <td>
@ -151,7 +151,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs-youtube-annotations.min.js?v=<%= CURRENT_COMMIT %>">videojs-youtube-annotations.min.js</a> <a href="/js/videojs-youtube-annotations.min.js?v=<%= ASSET_COMMIT %>">videojs-youtube-annotations.min.js</a>
</td> </td>
<td> <td>
@ -165,7 +165,7 @@
<tr> <tr>
<td> <td>
<a href="/js/video.min.js?v=<%= CURRENT_COMMIT %>">video.min.js</a> <a href="/js/video.min.js?v=<%= ASSET_COMMIT %>">video.min.js</a>
</td> </td>
<td> <td>
@ -179,7 +179,7 @@
<tr> <tr>
<td> <td>
<a href="/js/watch.js?v=<%= CURRENT_COMMIT %>">watch.js</a> <a href="/js/watch.js?v=<%= ASSET_COMMIT %>">watch.js</a>
</td> </td>
<td> <td>
@ -187,7 +187,7 @@
</td> </td>
<td> <td>
<a href="/js/watch.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a> <a href="/js/watch.js?v=<%= ASSET_COMMIT %>"><%= translate(locale, "source") %></a>
</td> </td>
</tr> </tr>
</table> </table>

View file

@ -6,20 +6,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="referrer" content="no-referrer"> <meta name="referrer" content="no-referrer">
<%= yield_content "header" %> <%= yield_content "header" %>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=<%= ASSET_COMMIT %>">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=<%= ASSET_COMMIT %>">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=<%= ASSET_COMMIT %>">
<link rel="manifest" href="/site.webmanifest"> <link rel="manifest" href="/site.webmanifest?v=<%= ASSET_COMMIT %>">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#575757"> <link rel="mask-icon" href="/safari-pinned-tab.svg?v=<%= ASSET_COMMIT %>" color="#575757">
<meta name="msapplication-TileColor" content="#575757"> <meta name="msapplication-TileColor" content="#575757">
<meta name="theme-color" content="#575757"> <meta name="theme-color" content="#575757">
<link title="Invidious" type="application/opensearchdescription+xml" rel="search" href="/opensearch.xml"> <link title="Invidious" type="application/opensearchdescription+xml" rel="search" href="/opensearch.xml">
<link rel="stylesheet" href="/css/pure-min.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/pure-min.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/grids-responsive-min.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/grids-responsive-min.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/ionicons.min.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/ionicons.min.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/default.css?v=<%= CURRENT_COMMIT %>"> <link rel="stylesheet" href="/css/default.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/darktheme.css?v=<%= CURRENT_COMMIT %>" id="dark_theme" <% if !env.get("preferences").as(Preferences).dark_mode %>media="none"<% end %>> <link rel="stylesheet" href="/css/darktheme.css?v=<%= ASSET_COMMIT %>" id="dark_theme" <% if !env.get("preferences").as(Preferences).dark_mode %>media="none"<% end %>>
<link rel="stylesheet" href="/css/lighttheme.css?v=<%= CURRENT_COMMIT %>" id="light_theme" <% if env.get("preferences").as(Preferences).dark_mode %>media="none"<% end %>> <link rel="stylesheet" href="/css/lighttheme.css?v=<%= ASSET_COMMIT %>" id="light_theme" <% if env.get("preferences").as(Preferences).dark_mode %>media="none"<% end %>>
</head> </head>
<% locale = LOCALES[env.get("preferences").as(Preferences).locale]? %> <% locale = LOCALES[env.get("preferences").as(Preferences).locale]? %>
@ -150,7 +150,7 @@
</div> </div>
<div class="pure-u-1 pure-u-md-2-24"></div> <div class="pure-u-1 pure-u-md-2-24"></div>
</div> </div>
<script src="/js/themes.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/themes.js?v=<%= ASSET_COMMIT %>"></script>
</body> </body>
</html> </html>

View file

@ -242,4 +242,4 @@ var video_data = {
</div> </div>
<% end %> <% end %>
</div> </div>
<script src="/js/watch.js?v=<%= CURRENT_COMMIT %>"></script> <script src="/js/watch.js?v=<%= ASSET_COMMIT %>"></script>