0

I Want to change site logo from my code..when user selects and image and save it..it is updated but site logo does not changed immidiately..and it is not always replicating..sometime i have to refresh the page for site logo change and sometimes it changed immidiately..

I am attaching the code for setting site logo from my form ,

File adminCompanyLogoPicFile = uploadRequest.getFile("admin_company_logo");
        imageUploadReq(userObj,adminCompanyLogoPicFile,actionRequest);


public static void imageUploadReq(User userObj, File fileType,ActionRequest actionRequest) throws IOException, PortalException, SystemException{
        byte[] bytes = FileUtil.getBytes(fileType);
        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
        if (Validator.isNotNull(userObj) && fileType != null && Validator.isNotNull(bytes) && bytes.length != 0) {
                if(siteLogoUpload){
                    LayoutSetLocalServiceUtil.updateLogo(themeDisplay.getScopeGroupId(), true, true, bytes);
                }else{
                    UserLocalServiceUtil.updatePortrait(userObj.getUserId(), bytes);
                }
        }
    }
Vinita Shah
  • 118
  • 2
  • 13

1 Answers1

1

There are several layers of cache that can possibly cause this: Liferay internally uses ehcache to keep some of the objects in memory. I'm not sure if this is relevant here as you update through the API - but the logo might also be cached by page. You can try it if you update the logo and then navigate to a page that never has been displayed (thus cached) since you last restarted your server.

Also, the logo might have some HTTP level cache information. Typically site logos don't change too often, so it'd be ok to instruct the browser to cache them for a while. You can test this by inspecting the DOM, display the logo and reload (or shift-reload) it in your browser, or by clearing your browser cache before refreshing the page.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • But if i refresh page then logo is displayed...I dont have to clear the cache manually...so if logo is stored in cache then it dont have to display on page refreshing....and if it is caching problem then how can i solve it via coding can u please give a code snippet... – Vinita Shah Jun 17 '16 at 12:12
  • Now I have no clue what you're asking: In your question it looks like the logo is not updated - in your comment it is updated. Please provide steps (preferably by editing the question) to reproduce the sequence that you're going through, your expectations and the actual observations. – Olaf Kock Jun 17 '16 at 15:47