掲示板

Appending parameters to CSS and JavaScript files to avoid caching issues

7年前 に Damon Morda によって更新されました。

Appending parameters to CSS and JavaScript files to avoid caching issues

New Member 投稿: 16 参加年月日: 15/07/02 最新の投稿
Hi folks,

We have a file that we include in our portal_normal.vm called app.min.js. This filename does not change and we've encountered issues where browsers are using outdated versions of that file, which can be expected since the filename does not change. We plan to make some changes in our web infrastructure configuration to force CSS and JS files to expire more frequently.

In addition we are thinking about appending a unique parameter onto the end of that file, such as app.min.js?t=1234556. We noticed that Liferay seems to do something similar and automatically for CSS and JS files. For example, here's the URLs to files that are produced by Liferay:

https://domain.com/our-portlet/js/my-portlet.js?browserId=other&minifierType=js&languageId=en_US&b=6210&t=1474018723000
https://domain.com/our-theme/css/main.css?browserId=other&themeId=company_WAR_ourtheme&minifierType=css&languageId=en_US&b=6210&t=1474002001000


Is there a way to append the same parameter(s) Liferay does to its CSS and JSS files in a Velocity template? Or does anyone have other suggestions?

Thanks in advance!
7年前 に Gautam Sharma によって更新されました。

RE: Appending parameters to CSS and JavaScript files to avoid caching issue

Junior Member 投稿: 92 参加年月日: 12/04/30 最新の投稿
Hi,

If you are working with plugin sdk, can you please check "preservelastmodified" property in build-common-theme.xml file

Open <plugins sdk folder >themes/build-theme-common.xml file. Find preservelastmodified=“true” and change to preservelastmodified=“false” or remove it.

Thanks