How to disable Liferay portlet cache?
I am developing a portlet for Liferay Portal.
I have disabled CSS and JavaScript caching by using these codes in portal-developer.properties file:
theme.css.fast.load=false theme.images.fast.load=false javascript.fast.load=false javascript.log.enabled=true layout.template.cache.enabled=false last.modified.c开发者_Python百科heck=false velocity.engine.resource.manager.cache.enabled=false com.liferay.portal.servlet.filters.cache.CacheFilter=false com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter=false
But I don't know how to disable portlet caching.
When I update view.jsp file in my portlet directory I have to restart Tomcat to see changes.
With the latest version, Liferay 6.2 you can turn on Development Mode.
When using the Liferay IDE
- Go to the Servers view and double click on the server
- Select Development Mode, save the configuration, and restart the server
When not using the Liferay IDE
- Edit setenv.sh or setenv.bat (for Windows) in $LIFERAY_DIR/$TOMCAT_DIR/bin/
- Add -Dexternal-properties=portal-developer.properties to the CATALINA_OPTS
Reference: https://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/using-developer-mode-with-themes-liferay-portal-6-2-dev-guide-09-en
I've had such problems with some misaligned clocks: When you edit the jsp through a network mount and your computer believes it's 10:00 while the server believes, that it's already 10:05, this is what might happen:
- You change the jsp at 10:01
- The tomcat sees it and compiles - everything works as expected, but the compiled page has a timestamp of 10:06
- You change the jsp again at 10:03
- Tomcat sees the changed timestamp and compares it with the timestamp of the compiled page: The compiled page is newer (timestamp-wise), so no compilation is done and the page doesn't reflect your update
- You get frustrated, restart tomcat, which takes 2 minutes
- You correct another error in the page, now it's timestamped 10:07
- Tomcat picks it up, compiles it...
Also, I believe to remember some "Context" configuration enabling to change jsp translation behaviour. Are you working on an unchanged liferay/tomcat bundle? Does the same happen when you're working on just one machine? Does the same thing happen when you take a new bundle, unzip and retry?
I found the solution use MultiVMPoolUtil.clear();
One of the things that tends to screw up JSP reloading is a timezone difference which causes an effect like the one Olaf Kock describes. Usually you can spot this in the log files as it will say something like "XXX has been modified in the future".
Because of these screwed up timestamps the new file won't we correctly detected and used. This can be easily solved by changing the timezone in the setenv.bat/setenv.sh file of Tomcat to an appropriate value.
Use the following line in doView method:
ABCUtil.clearCache()
and also can use <expiration-cache>0</expiration-cache>
in yours portlet deployment descriptor.
Why do you restart tomcat. Simply deploy your portlet into deploy directory. It's fastest. And if you run the Liferay from Eclipse IDE I think the changes are picked up automatically.
My issue was that deployment was not refeclting changes I maded to javascript source.
Create file named:
portal-ext.properties
Specifically in directory:
C:\liferay-portal-6.2-ce-ga4\jboss-7.1.1\standalone\deployments\ROOT.war\WEB-INF\classes\
With content:
com.liferay.portal.servlet.filters.cache.CacheFilter=false
Other Issues I had:
Shortccomings of windows filesystem not being able to accomodate long JBoss file/path namings in tmp directory.
Deployments were caching files I deleted
Builds were caching files I deleted
Lines in my bat file for build and deploy:
rd /q /s \liferay-portal-6.2-ce-ga4\jboss-7.1.1\standalone\tmp\work\jboss.web\default-host\my-portlet
rd /q /s \liferay-portal-6.2-ce-ga4\jboss-7.1.1\standalone\deployments\my-portlet.war
rd /q /s \liferay-portal-6.2-ce-ga4\liferay-plugins-sdk-6.2\portlets\my-portlet\docroot\WEB-INF\classes
ant.bat
精彩评论