Fórum

Enable cache for javascript and css

robin thakur, modificado 9 Anos atrás.

Enable cache for javascript and css

Regular Member Postagens: 146 Data de Entrada: 09/01/14 Postagens Recentes
Hi,

I want to enable caching in my portal, but I am getting below hit again and again on every page. Is there anyway that this URL hit once and store this file in cache.

http://localhost:8080/html/js/barebone.jsp?browserId=firefox&themeId=app_WAR_apptheme&colorSchemeId=01&minifierType=js&minifierBundleId=javascript.barebone.files&languageId=en_US&b=6200&t=1383314466000

similiar for other url for javascript that call from portlet.

http://localhost:8080/app-portlet/js/home.js?browserId=firefox&minifierType=js&languageId=en_US&b=6200&t=1418131069589

http://localhost:8080/app-portlet/js/cart.js?browserId=firefox&minifierType=js&languageId=en_US&b=6200&t=1418131069589

etc.

thanks
thumbnail
Tanweer Ahmed ., modificado 1 Ano atrás.

RE: Enable cache for javascript and css

Expert Postagens: 322 Data de Entrada: 11/03/10 Postagens Recentes
Hi Robin,

1. There are two ways through which javascript can be included in a Html Response.
i. embed js file directly in the response
ii. by referring to an independent js file.

Please make sure you follow the second way of including the js.This method will cache the js file in the browser cache.

2. Also make sure below property is set for Production javascript.fast.load=true .
With this property liferay combines all the js files in a single file to improve the performance.

3. Make sure your Portal minifier filter is enabled.

Hope this helps.

Regards,
Tanweer.
robin thakur, modificado 9 Anos atrás.

RE: Enable cache for javascript and css

Regular Member Postagens: 146 Data de Entrada: 09/01/14 Postagens Recentes
Hi Tanwer,

In my liferay-portlet.xml I have
<portlet>
<portlet-name>abc</portlet-name>
<icon>/icon.png</icon>
<layout-cacheable>true</layout-cacheable>
<instanceable>false</instanceable>
<header-portlet-css>/css/main.css</header-portlet-css>
<footer-portlet-javascript>
/js/abc.js
</footer-portlet-javascript>
<css-class-wrapper>abc-portlet</css-class-wrapper>
</portlet>

In portal-ext.properties I have
layout.template.cache.enabled=true
minifier.enabled=true
theme.css.fast.load=true
javascript.fast.load=true
theme.images.fast.load=true
velocity.engine.resource.manager.cache.enabled=true
javascript.log.enabled=false
com.liferay.portal.servlet.filters.cache.CacheFilter=true
minifier.inline.content.cache.size=10000
com.liferay.portal.servlet.filters.header.HeaderFilter=true
com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter=true


Tell me is there something missing.

Thanks & Regards