springroll.CacheManager Class

Module: Core

Used for managing the browser cache of loading external elements can easily load version manifest and apply it to the media loader supports cache busting all media load requests uses the query string to bust browser versions.

Constructor

springroll.CacheManager

(
  • app
)

Parameters:

_applyBasePath

(
  • url
)
String
private

Defined in _applyBasePath:262

Applies a base path to a relative url. This is not used in the filtering system because PreloadJS has its own method of prepending the base path that we use. Instead, it is used with an extra parameter to prepare().

Parameters:

  • url String

    The url to prepend the base path to.

Returns:

String:

The modified url.

_applyGlobalVersion

(
  • url
)
String
private

Applies cache busting or a global version to a url.

Parameters:

  • url String

    The url to apply versioning to.

Returns:

String:

The modified url.

_applySpecificVersion

(
  • url
)
String
private

Applies a url specific version to a url from the versions file.

Parameters:

  • url String

    The url to apply versioning to.

Returns:

String:

The modified url.

addVersion

(
  • url
  • version
)
public

Defined in addVersion:175

Add a version number for a file

Parameters:

  • url String

    The url of the object

  • version String

    Version number or has of file

addVersionsFile

(
  • url
  • callback
  • baseUrl
)
public

Defined in addVersionsFile:118

Adds a versions text file containing versions for different assets.

Parameters:

  • url String

    The url of the versions file.

  • callback Function

    Callback when the versions file has been loaded.

  • baseUrl String

    A base url to prepend all lines of the file.

destroy

()
public

Defined in destroy:104

Destroy the cache manager, don't use after this.

prepare

(
  • url
  • [applyBasePath=false]
)
String
public

Defined in prepare:281

Prepare a URL with the necessary cache busting and/or versioning as well as the base directory.

Parameters:

  • url String

    The url to prepare

  • [applyBasePath=false] Boolean optional

    If the global base path should be applied to the url. This defaults to false because it can potentially interfere with later regular expression checks, particularly with PreloadJS

Returns:

String:

The final url with version/cache and basePath added

registerURLFilter

(
  • filter
)
public

Adds a function for running all urls through, to modify them if needed. Functions used should accept one string parameter (the url), and return the modified url.

Parameters:

  • filter Function

    The function that will handle urls.

unregisterURLFilter

(
  • filter
)
public

Removes a function from the list of filtering functions.

Parameters:

  • filter Function

    The function to remove.

_app

springroll.Application protected

Defined in _app:28

The current application

_filters

Array protected

Defined in _filters:42

The list of URL filtering functions.

_globalVersion

String

Defined in _globalVersion:49

A global version or cache busting string to apply to every url.

_versions

Dictionary protected

Defined in _versions:35

The collection of version numbers

cacheBust

Boolean public

Defined in cacheBust:66

If we are suppose to cache bust every file

Default: false