Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Decide on your cache-busting strategy. In this example, we use the current timestamp, which will
* force a change every time the app is visited, but not every time the partial is loaded within a
* visit. Even better would be to use a hash of the file's contents to ensure that the file is always
* reloaded when the file changes and never reloaded when it isn't.
var cacheBustSuffix =;
// Optionally, expose the cache busting value as a constant so other parts of your app can use it.
ngModule.constant("cacheBustSuffix", cacheBustSuffix);
// Configure routing
ngModule.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/', {
//Append our cache busting value as a query parameter when we specify our templates
templateUrl: 'partials/dashboard.html?cache-bust=' + cacheBustSuffix,
controller: "DashboardCtrl"
$routeProvider.otherwise({redirectTo: '/'});
* What if we include a partial within another and it's not referenced directly as a route?
* This is one possible approach, though you may want to organize things differently.
ngModule.controller("EnterTimesheetCtrl", [
"$scope", "cacheBustSuffix", // we're using the constant declared above
function EnterTimesheetCtrl($scope, cacheBustSuffix) {
$scope.editableTemplateUrl = "partials/timesheet/editableTimesheet.html?cache-bust=" + cacheBustSuffix;
<div ng-include src="editableTemplateUrl"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.