Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature: cms:headincludes automatically adds the version id to the URI #612

Closed
wants to merge 1 commit into from

Conversation

Yuanuo
Copy link
Contributor

@Yuanuo Yuanuo commented Oct 26, 2018

Add feature: cms:headincludes automatically adds the version identifier of the static resource to the URI.

Cms:headincludes handles two static resources, css and js. If css and js are modified on the server side, it is difficult to ensure that the client gets updates in real time because the URI has not changed and the browser uses the cache.
Therefore, this feature mainly adds the latest release time of the resource to the URI of the static resource as the version identifier.
This ensures that the static resources are retrieved by the client to the latest version in real time after modification.

Usage: Actually, no additional code changes are required, because only one default processing item is added to the submitted implementation. So the default usage is fine.

For example, in apollo-page.jsp:

    <c:set var="theme"><cms:property name="apollo.theme" file="search" default="red" /></c:set>
    <c:choose>
      <c:when test="${fn:endsWith(theme, 'ap-includes.jsp')}">
          <cms:include file="${theme}" />
	  <cms:headincludes type="css" />
      </c:when>
      <c:otherwise>
          <c:if test="${not fn:startsWith(theme, '/')}">
             <c:set var="theme">/system/modules/org.opencms.apollo.theme/resources/css/style-${theme}.min.css</c:set>
          </c:if>
	  <cms:headincludes type="css" defaults="${theme}" />
      </c:otherwise>
    </c:choose>

Finally generate such code:

<link rel="stylesheet" href="/export/system/modules/org.opencms.apollo.theme/resources/css/style-red.min.css?ver=1531211047501" type="text/css" />

<script type="text/javascript" src="/export/system/modules/org.opencms.apollo.theme/resources/js/scripts-all.min.js?ver=1527845258074"></script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants