Message Boards
Local deploy of theme requires Tomcat restart
Jeff Hellman, modified 4 Years ago.
Local deploy of theme requires Tomcat restart
New Member Posts: 11 Join Date: 7/11/19 Recent Posts
When doing local development of my theme, the "gulp deploy" task appears to successfully deploy my theme .war to the local Tomcat instance, and indeed I can immediately see changes I make to the Freemarker templates. However, the main.css delivered to the browser doesn't have the most recent changes.
I can see in the .war that is deployed that the main.css does have my changes. It would appear that Tomcat keeps a cached version of that main.css file in the following location (for example):
...\liferay-dxp-7.2.10-ga1\tomcat-9.0.17\work\Catalina\localhost\ROOT\css\http__o_theme-name_css_main.css....
Is there a recommendation on how to clear that cache as part of the "gulp deploy"? I could do it manually but I'd prefer not to. I could also restart Tomcat each time I deploy but I want to do that even less than manually deleting the cache.
I can see in the .war that is deployed that the main.css does have my changes. It would appear that Tomcat keeps a cached version of that main.css file in the following location (for example):
...\liferay-dxp-7.2.10-ga1\tomcat-9.0.17\work\Catalina\localhost\ROOT\css\http__o_theme-name_css_main.css....
Is there a recommendation on how to clear that cache as part of the "gulp deploy"? I could do it manually but I'd prefer not to. I could also restart Tomcat each time I deploy but I want to do that even less than manually deleting the cache.
Patrick Yeo, modified 4 Years ago.
RE: Local deploy of theme requires Tomcat restart
Junior Member Posts: 61 Join Date: 2/8/13 Recent Posts
https://portal.liferay.dev/docs/7-2/frameworks/-/knowledge_base/f/using-developer-mode-with-themes
Put portal-ext.properties in the ...\liferay-dxp-7.2.10-ga1 directory and restart server. It should disable caching.
Put portal-ext.properties in the ...\liferay-dxp-7.2.10-ga1 directory and restart server. It should disable caching.
Jeff Hellman, modified 4 Years ago.
RE: Local deploy of theme requires Tomcat restart
New Member Posts: 11 Join Date: 7/11/19 Recent Posts
I added the portal-ext.properties to no effect unfortunately. The behavior is interesting, the following scenario plays out:
- Launch local Tomcat
- Load page in Chrome - see page load as expected
- Make a change to the theme and run "gulp deploy"
- Confirm the .war is deployed to Tomcat and see the "STARTED" message from the Bundle Listener
- Do a hard refresh/clear cache in Chrome, do not see the theme change
- Load page in Edge - see page load WITH the theme change
- Make another change to the theme and run "gulp deploy"
- Confirm the .war is deployed to Tomcat (same as before)
- Do a hard refresh/clear cache in Edge and Chrome, do not see the theme change in either browser
- Load page in Internet Explorer 11 - see page load WITH the first and second theme changes
- Do the same theme change/redeploy steps (#3 and #4) and see no change in Chrome/Edge/IE 11
- Does Tomcat keep track of what browser it has served content up to and cache it specifically that way?
- Is there something in the .css file URL or HTTP request headers that changes behavior on Tomcat for what it serves up?
- Does using DXP instead of CE for the Liferay version make a different in the developer properties I tried?
Jeff Hellman, modified 4 Years ago.
RE: Local deploy of theme requires Tomcat restart
New Member Posts: 11 Join Date: 7/11/19 Recent Posts
I am less baffled about the browser difference now, it looks like the requested URL does change with a browserId parameter, which in turn results in a new set of files in the Tomcat cache location:
C:\Liferay\liferay-dxp-7.2.10-ga1\tomcat-9.0.17\work\Catalina\localhost\ROOT\css
So now at least I understand why switching browsers works the first time, at which point point it will add the cache files and then subsequent requests with that browser get served those. So it's still a matter of server caching at this point.
C:\Liferay\liferay-dxp-7.2.10-ga1\tomcat-9.0.17\work\Catalina\localhost\ROOT\css
So now at least I understand why switching browsers works the first time, at which point point it will add the cache files and then subsequent requests with that browser get served those. So it's still a matter of server caching at this point.
Marco Endres, modified 3 Years ago.
RE: Local deploy of theme requires Tomcat restart
Regular Member Posts: 112 Join Date: 8/22/12 Recent Posts
I have sometimes the same problem. Did you find out more? Do yu know how I can clean those files without going to delete those files by hand?Marco
Jeff Hellman, modified 3 Years ago.
RE: Local deploy of theme requires Tomcat restart
New Member Posts: 11 Join Date: 7/11/19 Recent Posts
I ended up doing it by hand in an automated and slightly brittle fashion. I created a gulp task in my theme project and bound it to the deploy task from the existing liferay-theme-tasks - - code is as follows. You'll need to update your path accordingly, and this is the brittle piece since any changes to folder structure and this breaks.
var cachePath = 'C:/<path to your tomcat instance>/tomcat-9.0.17/work/Catalina/localhost/ROOT/css/';
var cacheFilePattern = "*liferay-federated-client-portal-theme*";
gulp.task('deploy:clean-cache', ['deploy'], function () {
// force the delete since this is outside the working directory and below
del(cachePath + cacheFilePattern, {
force: true
});
log("Cached CSS has been deleted from: " + cachePath + cacheFilePattern);
});
</path>
Marco Endres, modified 3 Years ago.
RE: Local deploy of theme requires Tomcat restart
Regular Member Posts: 112 Join Date: 8/22/12 Recent Posts
Thank you very much. This could be really useful next time
Jeff Hellman, modified 3 Years ago.
RE: Local deploy of theme requires Tomcat restart
New Member Posts: 11 Join Date: 7/11/19 Recent Posts
Honestly, I just got in the habit of running `gulp deploy:clean-cache` instead of the regular `gulp deploy` and figured I never cared whether the cache was still there
Marco Endres, modified 3 Years ago.
RE: Local deploy of theme requires Tomcat restart
Regular Member Posts: 112 Join Date: 8/22/12 Recent Posts
Do you also had the problems on test or prod-environments? Where you only deploy the .war?
Milan Riha, modified 3 Years ago.
RE: Local deploy of theme requires Tomcat restart
New Member Posts: 6 Join Date: 8/9/08 Recent Posts
Hi,what work for me in LR 7.3 is change theme version in package.json and make any change directly in main.scss file, even if not needed. For example when I change only imported file.
Marco Endres, modified 3 Years ago.
RE: Local deploy of theme requires Tomcat restart
Regular Member Posts: 112 Join Date: 8/22/12 Recent PostsMaybe it helps somebody :)
https://github.com/liferay/liferay-frontend-projects/issues/402