Skip to content

Commit

Permalink
Improve static asset build process and cache headers (#2560)
Browse files Browse the repository at this point in the history
This PR improves the static asset build process by using the Mix build
system to copy all static files instead of only those which are compiled
or relocated. By making Mix aware of all of the static assets, the
`mix()` helper function can be used to add cache busting extensions to
all static asset file paths. This in turn allows an aggressive cache
policy to be put in place. Although the caching policy only resulted in
a marginal speedup in my local environment, I expect it to have a more
significant impact in production environments where assets have to
travel a greater distance.
  • Loading branch information
williamjallen authored Nov 15, 2024
1 parent a6cdddb commit 236cfd4
Show file tree
Hide file tree
Showing 136 changed files with 176 additions and 166 deletions.
106 changes: 52 additions & 54 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,57 +1,55 @@
vendor/*
public/laravel/*
public/build/*
_build/*
cypress_cache/*
app/cdash/public/*
public/js/ui.tabs.js
public/js/tabNavigation.js
public/js/services/renderTimer.js
public/js/services/multisort.js
public/js/services/modal.js
public/js/services/filters.js
public/js/services/comparators.js
public/js/services/apiLoader.js
public/js/services/anchors.js
public/js/linechart.js
public/js/jquery.tablesorter.js
public/js/jquery.metadata.js
public/js/je_compare.js
public/js/filters/terminalColors.js
public/js/filters/showEmptySubProjectsLast.js
public/js/directives/timeline.js
public/js/directives/onFinishRender.js
public/js/directives/daterange.js
public/js/directives/convertToNumber.js
public/js/directives/buildgroup.js
public/js/directives/build.js
public/js/directives/autocomplete.js
public/js/controllers/viewTest.js
public/js/controllers/viewSubProjects.js
public/js/controllers/viewDynamicAnalysisFile.js
public/js/controllers/viewBuildError.js
public/js/controllers/userStatistics.js
public/js/controllers/testSummary.js
public/js/controllers/testOverview.js
public/js/controllers/subproject.js
public/js/controllers/queryTests.js
public/js/controllers/overview.js
public/js/controllers/manageSubProject.js
public/js/controllers/manageOverview.js
public/js/controllers/manageBuildGroup.js
public/js/controllers/index.js
public/js/controllers/head.js
public/js/controllers/filters.js
public/js/controllers/compareCoverage.js
public/js/controllers/buildProperties.js
public/js/cdash_angular.js
public/js/cdashViewCoverage.js
public/js/cdashUploadFilesSorter.js
public/js/cdashSortable.js
public/js/cdashSiteSorter.js
public/js/cdashProjectRole.js
public/js/cdashManageUsers.js
public/js/cdashManageCoverageSorter.js
public/js/cdashFilters.js
public/js/cdashCoverageGraph.js
public/js/bulletchart.js
public/assets/*
resources/js/angular/ui.tabs.js
resources/js/angular/tabNavigation.js
resources/js/angular/services/renderTimer.js
resources/js/angular/services/multisort.js
resources/js/angular/services/modal.js
resources/js/angular/services/filters.js
resources/js/angular/services/comparators.js
resources/js/angular/services/apiLoader.js
resources/js/angular/services/anchors.js
resources/js/angular/linechart.js
resources/js/angular/jquery.tablesorter.js
resources/js/angular/jquery.metadata.js
resources/js/angular/je_compare.js
resources/js/angular/filters/terminalColors.js
resources/js/angular/filters/showEmptySubProjectsLast.js
resources/js/angular/directives/timeline.js
resources/js/angular/directives/onFinishRender.js
resources/js/angular/directives/daterange.js
resources/js/angular/directives/convertToNumber.js
resources/js/angular/directives/buildgroup.js
resources/js/angular/directives/build.js
resources/js/angular/directives/autocomplete.js
resources/js/angular/controllers/viewTest.js
resources/js/angular/controllers/viewSubProjects.js
resources/js/angular/controllers/viewDynamicAnalysisFile.js
resources/js/angular/controllers/viewBuildError.js
resources/js/angular/controllers/userStatistics.js
resources/js/angular/controllers/testSummary.js
resources/js/angular/controllers/testOverview.js
resources/js/angular/controllers/subproject.js
resources/js/angular/controllers/queryTests.js
resources/js/angular/controllers/overview.js
resources/js/angular/controllers/manageSubProject.js
resources/js/angular/controllers/manageOverview.js
resources/js/angular/controllers/manageBuildGroup.js
resources/js/angular/controllers/index.js
resources/js/angular/controllers/head.js
resources/js/angular/controllers/filters.js
resources/js/angular/controllers/compareCoverage.js
resources/js/angular/controllers/buildProperties.js
resources/js/angular/cdash_angular.js
resources/js/angular/cdashViewCoverage.js
resources/js/angular/cdashUploadFilesSorter.js
resources/js/angular/cdashSortable.js
resources/js/angular/cdashSiteSorter.js
resources/js/angular/cdashProjectRole.js
resources/js/angular/cdashManageUsers.js
resources/js/angular/cdashManageCoverageSorter.js
resources/js/angular/cdashFilters.js
resources/js/angular/cdashCoverageGraph.js
resources/js/angular/bulletchart.js
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ RUN sed -i 's/Listen 80/Listen 8080/g' /etc/apache2/ports.conf
RUN a2dissite 000-default && \
a2ensite cdash-site && \
a2enmod rewrite && \
a2enmod php
a2enmod php && \
a2enmod headers

# Enable https site if we're not doing a development build.
RUN if [ "$DEVELOPMENT_BUILD" != '1' ]; then \
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function angular_view(string $view): View
}

return $this->view('cdash')
->with('xsl_content', file_get_contents(base_path("public/build/views/$view.html")))
->with('xsl_content', file_get_contents(base_path("public/assets/js/angular/views/$view.html")))
->with('xsl', true)
->with('angular', true)
->with('angular_controller', $controller_name);
Expand Down
4 changes: 2 additions & 2 deletions app/cdash/include/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,8 @@ function getByteValueWithExtension($value, $base = 1024): string
*/
function get_css_file(): string
{
$classic = 'build/css/cdash.css';
$colorblind = 'build/css/colorblind.css';
$classic = 'assets/css/cdash.css';
$colorblind = 'assets/css/colorblind.css';

if (array_key_exists('colorblind', $_COOKIE) && $_COOKIE['colorblind'] == 1) {
return $colorblind;
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/include/filterdataFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ function get_filterdata_from_request($page_id = '')
if (array_key_exists('colorblind', $_COOKIE)) {
$filterdata['colorblind'] = intval($_COOKIE['colorblind']);
} else {
if (get_css_file() === 'build/css/colorblind.css') {
if (get_css_file() === 'assets/css/colorblind.css') {
$filterdata['colorblind'] = 1;
} else {
$filterdata['colorblind'] = 0;
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/public/manageCoverage.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@

</xsl:if>

<script src="js/cdashManageCoverageSorter.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/js/angular/cdashManageCoverageSorter.js" type="text/javascript" charset="utf-8"></script>

</xsl:template>
</xsl:stylesheet>
4 changes: 2 additions & 2 deletions app/cdash/public/manageProjectRoles.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@
</xsl:otherwise>
</xsl:choose>

<script src="js/cdashProjectRole.js" type="text/javascript"></script>
<script src="js/ui.tabs.js" type="text/javascript"></script>
<script src="assets/js/angular/cdashProjectRole.js" type="text/javascript"></script>
<script src="assets/js/angular/ui.tabs.js" type="text/javascript"></script>


<!-- Functions to confirm the email -->
Expand Down
6 changes: 3 additions & 3 deletions app/cdash/public/viewCoverage.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@
</thead>
</table>

<script src="js/cdashCoverageGraph.js" type="text/javascript" charset="utf-8"></script>
<script src="js/cdashFilters.js" type="text/javascript" charset="utf-8"></script>
<script src="js/cdashViewCoverage.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/js/angular/cdashCoverageGraph.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/js/angular/cdashFilters.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/js/angular/cdashViewCoverage.js" type="text/javascript" charset="utf-8"></script>

</xsl:template>
</xsl:stylesheet>
2 changes: 1 addition & 1 deletion app/cdash/public/viewMap.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</xsl:if>
</div>

<script language="javascript" type="text/javascript" src="js/cdashSiteSorter.js"></script>
<script language="javascript" type="text/javascript" src="assets/js/angular/cdashSiteSorter.js"></script>

</xsl:template>
</xsl:stylesheet>
7 changes: 2 additions & 5 deletions config/cdash.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
'file' => [
'path' => [
'js' => [
'controllers' => base_path("public/js/controllers"),
'version' => base_path("public/build/js/version.js"),
],
'custom' => [
'views' => base_path("public/local/views"),
'controllers' => base_path("public/assets/js/angular/controllers"),
'version' => base_path("public/assets/js/angular/version.js"),
],
'public' => base_path("public"),
],
Expand Down
6 changes: 6 additions & 0 deletions public/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

<IfModule mod_headers.c>
<FilesMatch "\.(css|js|svg|gif|png)$">
Header set Cache-Control "max-age=31536000"
</FilesMatch>
</IfModule>
File renamed without changes.
7 changes: 0 additions & 7 deletions public/css/bootstrap.min.css

This file was deleted.

7 changes: 7 additions & 0 deletions resources/css/bootstrap.min.css

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions public/css/common.css → resources/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ a.grouptrigger:visited{
.tabs-nav a, .tabs-nav a span {
display: block;
padding: 0 10px;
background: url(../img/tab.png) no-repeat;
background: url(../../public/img/tab.png) no-repeat;
}
.tabs-nav a {
position: relative;
Expand Down Expand Up @@ -257,7 +257,7 @@ a.grouptrigger:visited{
}
.tabs-loading em {
padding: 0 0 0 20px;
background: url(../img/loading.gif) no-repeat 0 50%;
background: url(../../public/img/loading.gif) no-repeat 0 50%;
}
div.tab_content {
border:1px solid #97A5B0;
Expand Down Expand Up @@ -448,25 +448,25 @@ div#calendar{
}

.activity-level-none {
background: url(../img/activity-level.png) no-repeat scroll -16px -16px transparent;
background: url(../../public/img/activity-level.png) no-repeat scroll -16px -16px transparent;
height: 16px;
width: 16px;
}

.activity-level-low {
background: url(../img/activity-level.png) no-repeat scroll 0 -16px transparent;
background: url(../../public/img/activity-level.png) no-repeat scroll 0 -16px transparent;
height: 16px;
width: 16px;
}

.activity-level-medium {
background: url(../img/activity-level.png) no-repeat scroll -16px 0 transparent;
background: url(../../public/img/activity-level.png) no-repeat scroll -16px 0 transparent;
height: 16px;
width: 16px;
}

.activity-level-high {
background: url(../img/activity-level.png) no-repeat scroll 0 0 transparent;
background: url(../../public/img/activity-level.png) no-repeat scroll 0 0 transparent;
height: 16px;
width: 16px;
}
Expand Down Expand Up @@ -861,14 +861,14 @@ div#headertop {
}

#header .projectnav .projectnav_controls li.btnprev a:before {
background:url(../img/prev-chevron.svg) no-repeat center center;
background:url(../../public/img/prev-chevron.svg) no-repeat center center;
background-size:100%;
float:left;
margin:2px 10px 0 0;
}

#header .projectnav .projectnav_controls li.btnnext a:after {
background:url(../img/next-chevron.svg) no-repeat center center;
background:url(../../public/img/next-chevron.svg) no-repeat center center;
background-size:100%;
float:right;
margin:2px 0 0 10px;
Expand Down Expand Up @@ -1070,10 +1070,10 @@ div#main_content {
cursor: pointer;
}
.tabb thead tr .headerSortUp {
background-image: url(../img/asc.gif);
background-image: url(../../public/img/asc.gif);
}
.tabb thead tr .headerSortDown {
background-image: url(../img/desc.gif);
background-image: url(../../public/img/desc.gif);
}
.tabb thead tr .headerSortDown, .tabb thead tr .headerSortUp {
background-color: #adcae6
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ table.dataTable tr.even td.sorting_3 { background-color: #F9F9FF; }
margin-left: 10px;
}

.paginate_enabled_previous { background: url('../img/back_enabled.png') no-repeat top left; }
.paginate_enabled_previous:hover { background: url('../img/back_enabled_hover.png') no-repeat top left; }
.paginate_disabled_previous { background: url('../img/back_disabled.png') no-repeat top left; }
.paginate_enabled_previous { background: url('../../public/img/back_enabled.png') no-repeat top left; }
.paginate_enabled_previous:hover { background: url('../../public/img/back_enabled_hover.png') no-repeat top left; }
.paginate_disabled_previous { background: url('../../public/img/back_disabled.png') no-repeat top left; }

.paginate_enabled_next { background: url('../img/forward_enabled.png') no-repeat top right; }
.paginate_enabled_next:hover { background: url('../img/forward_enabled_hover.png') no-repeat top right; }
.paginate_disabled_next { background: url('../img/forward_disabled.png') no-repeat top right; }
.paginate_enabled_next { background: url('../../public/img/forward_enabled.png') no-repeat top right; }
.paginate_enabled_next:hover { background: url('../../public/img/forward_enabled_hover.png') no-repeat top right; }
.paginate_disabled_next { background: url('../../public/img/forward_disabled.png') no-repeat top right; }

/* Full number pagination */
.paging_full_numbers {
Expand Down Expand Up @@ -194,12 +194,12 @@ table.dataTable tr.even td.sorting_3 { background-color: #F9F9FF; }
/*
* Sorting
*/
.sorting { background: url('../img/sort_both.png') no-repeat center right; }
.sorting_asc { background: url('../img/sort_asc.png') no-repeat center right; }
.sorting_desc { background: url('../img/sort_desc.png') no-repeat center right; }
.sorting { background: url('../../public/img/sort_both.png') no-repeat center right; }
.sorting_asc { background: url('../../public/img/sort_asc.png') no-repeat center right; }
.sorting_desc { background: url('../../public/img/sort_desc.png') no-repeat center right; }

.sorting_asc_disabled { background: url('../img/sort_asc_disabled.png') no-repeat center right; }
.sorting_desc_disabled { background: url('../img/sort_desc_disabled.png') no-repeat center right; }
.sorting_asc_disabled { background: url('../../public/img/sort_asc_disabled.png') no-repeat center right; }
.sorting_desc_disabled { background: url('../../public/img/sort_desc_disabled.png') no-repeat center right; }

table.dataTable th:active {
outline: none;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ function FiltersController($scope, $rootScope, $http, $timeout) {
angular.module('CDash')
.directive('filterRow', ["VERSION", function (VERSION) {
return {
templateUrl: 'build/views/partials/filterRow.html?id=' + VERSION,
templateUrl: 'assets/js/angular/views/partials/filterRow.html?id=' + VERSION,
};
}]);

angular.module('CDash')
.directive('filterButtons', ["VERSION", function (VERSION) {
return {
templateUrl: 'build/views/partials/filterButtons.html?id=' + VERSION,
templateUrl: 'assets/js/angular/views/partials/filterButtons.html?id=' + VERSION,
};
}]);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ CDash.controller('ViewBuildErrorController',
};
}]).directive('buildError', ["VERSION", function (VERSION) {
return {
templateUrl: 'build/views/partials/buildError.html?id=' + VERSION,
templateUrl: 'assets/js/angular/views/partials/buildError.html?id=' + VERSION,
};
}]);
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CDash.directive('build', ["VERSION", function (VERSION) {
return {
templateUrl: 'build/views/partials/build.html?id=' + VERSION,
templateUrl: 'assets/js/angular/views/partials/build.html?id=' + VERSION,
}
}]);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CDash.directive('buildgroup', ["VERSION", function (VERSION) {
return {
templateUrl: 'build/views/partials/buildgroup.html?id=' + VERSION,
templateUrl: 'assets/js/angular/views/partials/buildgroup.html?id=' + VERSION,
}
}]);
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CDash.directive('daterange', ["VERSION", function (VERSION) {
return {
restrict: 'A',
templateUrl: 'build/views/partials/daterange.html?id=' + VERSION,
templateUrl: 'assets/js/angular/views/partials/daterange.html?id=' + VERSION,
link: function (scope, element, attrs, ngModelCtrl) {
var format = "yy-mm-dd",

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ timelineController.$inject = ["$http", "$scope"];
CDash.directive('timeline', ["VERSION", function (VERSION) {
return {
restrict: 'A',
templateUrl: 'build/views/partials/timeline.html?id=' + VERSION,
templateUrl: 'assets/js/angular/views/partials/timeline.html?id=' + VERSION,
controller: timelineController
};
}]);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<span ng-show="showfilters != 0">Hide Filters</span>
</a>
</div>
<ng-include src="'build/views/partials/filterdataTemplate.html?id=' + VERSION"></ng-include>
<ng-include src="'assets/js/angular/views/partials/filterdataTemplate.html?id=' + VERSION"></ng-include>

<!-- Coverage -->
<table border="0" cellpadding="4" cellspacing="0" width="100%" class="tabb" id="coveragetable">
Expand Down
Loading

0 comments on commit 236cfd4

Please sign in to comment.