How to disable js and css caching in liferay? - liferay

I am developing a theme for liferay,but liferay caching system does not let me to see changes.
How can i disable liferay js and css caching?
PS: I am using Liferay version 5.1.1

Under Tomcat (bundled)
Edit the setenv.sh file (setenv.bat on windows)
Search for the line that sets the JAVA_OPTS variable
Add -Dexternal-properties=portal-developer.properties to the list of options
For example:
JAVA_OPTS="-Xms256m -Xmx1024m -XX:PermSize=32m -XX:MaxPermSize=160m -Dfile.encoding=UTF8 -Duser.timezone=GMT+2
-Djava.security.auth.login.config=$CATALINA_HOME/conf/jaas.config
-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false
-Dexternal-properties=portal-developer.properties"
Note that this has to be all on one line.
If you were already using the external-properties system property to load some other properties file, add portal-developer.properties with commas.
This is however for the later version 5.2.3+
Not sure why you are still # 5.1.1, I would update to take advantage of some updated structure and dev handling. In the past there was more work required to get the caching disabled.
Reference:
http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Liferay%2BDeveloper%2BMode

it's all about Liferay servlet filters. You need to turn some of them off. The best place for that is portal-developer-ext.properties.
You make liferay read it by 2 possible ways :
JVM parameter -Dexternal-properties=portal-developer-ext.properties
or add this property to portal-ext.properties
include-and-override=portal-developer-ext.properties

To disable caching of JS and CSS resources in Liferay Portal 6.1+*, add the following line to your portal-ext.propeties file:
browser.cache.disabled=true
*This may work in older versions as well, but I haven't tested it.

Below link have complete details how to manage caching in liferay
http://www.liferay.com/community/forums/-/message_boards/message/10626805

Related

Do I need to update log4j.properties file if I use the Log4j 1.x bridge (log4j-1.2-api)

I've followed the doc here : https://logging.apache.org/log4j/2.x/manual/migration.html
Also looked at https://logging.apache.org/log4j/2.x/manual/configuration.html#Properties
My existing log4j.properties only uses DailyRollingFileAppender, ConsoleAppender, both of which are under the 'Supported Components', so I shouldn't be forced to convert my log4j.properties file into log4j2.properties format. I'm not accessing methods and classes internal to the Log4j 1.x implementation, as suggested by the document.
For using the bridge, I previously was using both log4j1.compatibility and log4j.configuration, but the document suggests using 'any one' (tried using just one, doesn't work)
I can build my application successfully, however, my application no longer logs anything. What am I missing?
You may want to consider reload4j as a drop-in replacement for log4j 1.x. Initiated by Ceki Gülcü, the original author of Apache log4j 1.x, the reload4j project is a fork of Apache log4j version 1.2.17 with the goal of fixing pressing security issues.
The reload4j project offers a clear and easy migration path for the users who have an urgent need to fix vulnerabilities in log4j 1.2.17.
You don't need to update your properties file.
You can add a log4j2.component.properties file on the class path (in my case, in the same directory as my log4j.properties file) to set the log4j1.compatibility property, like this:
log4j1.compatibility=true
In our case, it only required setting the compatibility property and then it automatically picked up the log4j.properties file that was available on the class path.
Figured it out.
The answer lied in the Automatic Configuration section

where is war exploded in Liferay 7 tomcat after getting copied in osgi folder

I deployed a portlet in liferay 7 and it got deployed successfully and was available for use. I want to replace the jsp file, in earlier version I could see my application in tomcat/webapps folder and replace it quickly.
Now I am unable to locate the exploded war in liferay 7. I can only see the war in osgi/war folder.
Can someone help me with that.
Thanks in advance.
While I mostly agree with what Olaf wrote, I do understand the need to be able to make changes in JSP files and try them quickly during development. I'm afraid I don't have the solution for that yet.
However, let me answer the question you asked:
where is war exploded in Liferay 7 tomcat after getting copied in osgi folder
It is NOT (at least not the way it was done by application servers)! When you deploy a WAR file in Liferay 7, it will automatically (on the fly) convert it into OSGi bundle and install it in OSGi runtime. This way now Liferay is fully in charge of deploying plugins and does not need to rely on various application servers.
PLEASE NOTE: Every bundle has it's own state folder. In Liferay those are in <LIFERAY_HOME>/osgi/state. If you know the bundle ID you can easily find it. It may be (I haven't checked) that you'll find some JSP files there. The reason I'm writing this is to warn you (in case you figured it yourself) to NEVER modify bundle's state folder manually. Doing so may brake the whole environment. In worse case scenario you may have to redeploy everything in clean environment.
You should not rely on behavior like this. In previous versions it was the task of the application server to compile changed JSPs at runtime. However, this is bad practice in production systems and totally screws up your maintainability. If you need to update some UI code frequently, I'm suggesting you change your implementation to utilize ADT (Application Display Templates), e.g. through Freemarker or Velocity. Those are meant to be updated at runtime, where the JSP updates were a side effect of Tomcat's default (development friendly, production hostile) configuration

Exclude Liferay's OSGI bundle on Startup

I have installed Liferay 7 to develop application. When Liferay 7 started, I found that it started more then 400+ OSGI bundles/services. So is there any way that we configure Liferay to only load specific bundles only? Or we can provide list of OSGI bundles/services to be excluded on start up of Liferay?
You can simply delete the ones that you don't need. This way they won't be started. Note that there might be dependent bundles that also won't start when their dependencies are not met, but you probably expected that. So if you're missing functionality after removing some bundles, you probably have deleted too many of them (or the wrong ones).

Where to put a library shared between portlets in Liferay?

I need to share a library (built in-house) between portlets and I prefer to put it in a common place instead of adding it as dependency to every portlet that need it because I want to update the library once. Can I build a hook or ext plugin that the portlets can refer to and access the library? I know that you can add it to the common library directory and add it to liferay-plugin-package.properties for each portlet but the location depends on the application server. I want to know, there is a standard or cleaner way to do this? Thanks in advance.
With the tomcat bundle, the common usage is to put these in the tomcat/lib/ext folder.
There is one big drawback, every modification in this folder will require a server restart.

Changes to init_custom.vm not showing up

I'm building a new Liferay theme and being crushed by this problem.
When I make changes to the init_custom.vm, the only possible way for me to see the changes is to restart Tomcat. When I make other changes to my theme, such as editing my CSS or adding images, I can see the changes after deploying the theme via the Ant Deploy target. No such luck with the templates.
I checked the $CATALINA_HOME/webapps/my-theme/init_custom.vm after deploying, and that file does reflect my changes.
I cannot continue to develop if this is going to be the cycle. I must be able to make changes to the velocity template without requiring a restart. Any suggestions?
I'm using the Eclipse Liferay IDE and the Ant build to deploy my theme when I make changes. I'm using the Liferay 6.0.6 Tomcat bundle. I've also already added include-and-override=portal-developer.properties to my portal-ide.properties file.
Thanks!!!
(also asked this in the Liferay Forums, and I'll make sure to copy back any answers I get: http://www.liferay.com/community/forums/-/message_boards/message/11292911)
Liferay also caches everything Velocity related which sometimes can present itself in the way you describe: changes to templates don't seem to show unless you restart Liferay. You can turn off this behavior if you set the following property in your portal-ext.properties file:
velocity.engine.resource.manager.cache.enabled=false
I switched to the 6.1 Beta and do not have the problem on that release, so it was just with 6.0.6.
Also: I've seen How to edit a velocimacro without restarting velocity? and Testing JSON API in Rails 3.2 using rspec using exact PUT/POST bodies as Backbone would send and they did not work for me. Upgrading to 6.1 beta did, for some reason, work.

Resources