Monday, June 17, 2019

Performance: Image optimization

If you check your website using Google's tool: Pagespeed Insights, one of the basic issues with many websites is that images are not optimal for mobile devices and possible for desktop as well. As more and more people consume information via mobiles and tablets, it is very crucial for your website to be very fast and friendlier. In case of friendlier, it itself is a big topic and is out-of-scope with respect to WCS. But when it comes to performance, one of the major challenges with WCS is blobs handling and displaying correct dimension of images according to mobile and desktop devices.
Thus, I have listed down a few points which I found one should definitely try and make their site performant than now it is, if by not much.
  1. URL handling: Vanity URL is one of the best feature introduced with WCS 11g8 which has altogether removed the usage of assemblers (which used to be in old product of WCS erstwhile FatWire). Should you have vanity urls for blobs as they are simply images / docs and they don't need any urls as they are simply displayed directly. But there may a case wherein a customer might want to share image / document url to other platforms which should not change with time as people may bookmark or share it further across other channels. This is where it is important to have vanity url for blobs as well. I propose the following solution which has worked for our clients until now: In order to have vanity url for blob, you simply select blobs on vanity url screen and check "Is downloadable?" as needed. Most important thing is url pattern which one needs to configure which we learnt from our past mistakes and works well be it clustered or non-clustered infrastructure. URL pattern like following works quite well: /[may be locale value for e.g. en]/[asset id of the asset]/[blobname].[extension] for e.g. /en/1234/image1.png Having asset id within the URL itself is perfect for situation wherein RSS or WCS are clustered. Furthermore, you can add more blob header information as well with Vanity URL.
  2. Rendering / displaying images: I particularly said images not documents because WCS based websites are mostly text and images. For text, there are few compression techniques and they work well (check white space compression). For images, it is quite difficult to display the appropriate image which fits the section of a website. From my past experience, usually content editors use the same image across small box items to sliders to search boxes, etc. which becomes bottleneck for rendering the page fast as the browser may take time to download & serve the images to an end user. If you really have websites with very big images in size and dimension that can really hurt user experience if not performant enough. So how to tackle ? These are few ways which worked for us:
    • Use CDN (Content Delivery Network): This is known to many and is used to make their website faster for better user experience but does comes at a cost of configuration and maintenance.
    • Cache your images to higher TTL: This requires quite good amount of time to figure out the optimal time for images to cache and that can be still be not good enough. Configuration within WCS and RSS is another challenge.
    • Don't allow users to upload images higher than certain size. This can be achieved using WCS and already described in the developer guide (check Uploader). But still some images do need to be higher in dimension and customer may not have the most optimized image.
    • Use webserver to serve images: As it seems easier to say, it is little bit harder to make it work properly as challenge comes on how to handle during publishing and not to mention adding / updating / deleting images can also be quite tricky to setup. May be there are already such plugins available but still requires quite an effort to make it work smoothly.
    • Compress your images using free / paid services as mentioned by Google. This is what we have used for one of the clients where they have nearly thousands of images to display on their websites and thus, optimal compressed images are displayed. Clients uploads an image, which on saving asset calls the external API which provides compressed and good quality of image, store in an attribute and use the compressed image for displaying on website.
    • Use OOTB ImageOptimizationFilter flex filter: This one is my favorite as this particular flex filter generates good quality of optimized and resized images for devices configured within WCS. But as I have known from past that many customers don't want to contribute content for Touch, Desktop and NonTouch devices within WCS as that task is very tedious and repeatative, this filter may not be that helpful. For those who are already use devices, they can refer on how to use this flex filter and optimize images. For those who don't use devices or mobility feature much, still can use this filter in following way: Just follow the steps mentioned in the above link and create renditions of the images as needed which would generate 2 images: [your image name]_Touch and [your image anem]_NonTouch. As a customer or development team, you should already know which sizes of images would fit in which sections. You can display accordingly either Touch or NonTouch image and thus, can save quite a lot of bandwidth for your end users. This particularly filter is quite useful which not only compresses image size but also provides 2 renditions of images with good quality. If you need more renditions, then you can definitely write your own custom implementation of ImageOptimizationFilter as mentioned in the guide. This flex filter is optimized within 12c and works quite well.
    • Use webserver to configure default expiration for images of about certain optimal value like 7 days, 1 month or even 1 year. This is subject to client's wishes and needs to be catered accordingly.
    • Last but not least, using combination of above is certainly going to achieve a faster and good experience for end users.
There may be other tricks as well to handle image compression and optimization but I guess this should provide some hints on tackling performance related to images.

Need help? Click here.

Should you upgrade to WCS 12c?

It been long since Oracle introduced new version of WCS i.e. 12c and till now 4 versions of WCS have been released, you can check the details about releases on the official website here. You may want to check which are all the new and deprecated features; which I have already listed on this blog post.
Now the bigger question, why one should consider upgrading to WCS 12c. Are there any advantages on using 12c version of WCS rather than 11g ? I, myself, don't know much information about it but let's just dig into it and try to figure out what are possible reasons for you or your clients to upgrade.
  1. RIP 11g: First of all, if you are already a client or working for client on WCS project, you might already know by now that WCS 11g is discontinued and is subject to just extended support. Thus, there is no way one would like to continue using deprecated version of WCS. Not only that, Oracle stops providing fixes in form of patches once the product is discontinued, thus, it makes no brainer to figure out that you or your client needs to upgrade to WCS 12c as soon as possible.
  2. Improvements: Frankly speaking, a lot of effort has been made by Oracle in order to improve user and developers experience by improving the way it used to work in 11g. Many new features have been introduced which would help not only the contributors on how they work within WCS but also developers after introduction of new mode of development (MVC and aggregate REST API). Thus, kudos to Oracle for working so hard on introducing these features and streamlining the product.
  3. Integration to other relevant products: This is one of the best feature introduced within WCS 12c where various integration points to different products are targeted mainly for marketers and editors to enhance the web user experience before the release of the desired content on their websites. Few of the integration with other products like Oracle document cloud, Oracle Eloqua, Oracle CEC, Blukai, WebCenter Content, etc. really allows wider groups to collaborate and contribute to website with rich content within an organization. With A/B testing, it is possible to test, analyze and publish more appropriate content which suits your organization. Content Targeting with Blukai  is even easier. You can contribute your content on the fly on any device by integrating WCS with Oracle Document Cloud service. Any REST based services are capable of being integrated with WCS using proxy assets. Thus, there is now larger scope of integrating with other non-Oracle products as well within WCS.
  4. Easier for developers. Is it? Well, with introduction of MVC in WCS, I would say that it was long desired feature but really does it helps ? I don't think so. In my experience, WCS at first seems very easy product to understand and use for development but as you dig more into development and designing (which is the most important aspect for WCS projects), you will find that with introduction of MVC, it is now very crucial to built a solution which should be very optimal, easily readable and planned with more precision. Just browse through code base of avisports sample website which is shipped with Jump Start Kit (available at Oracle edelivery website), code base has grown too much and with every new layout/section, a WCS controller is needed. Basically, you might end up with so many controllers and layouts which can be quite confusing and difficult for developers to understand for bigger projects.
  5. APIs: Well, it seems Oracle did provide a robust API for content fetching, searching and rendering easier. With JSTL tags, it can be little tricky but once you get used to it, it is okay. Not that bad. Other APIs like the new aggregate REST api is good and Java APIs are updated too.
  6. Design: According to me, in past few years, whichever projects I have handled as consultant or architect or developer, the most challenging part was and is design when it comes to WCS. If you don't design content model well, be ready to face hell lot of issues while migrating, upgrading, publishing and deploying. There are currently no standards provided by Oracle for content model and template designs and that's where I feel people lack interest in product due to the complexity which grows as the project goes on. In 12c, its same so again nothing new.
  7. Others: There are a few tweaks here and there but are not listed in the official documentations. Left for the developers to decipher that.
  8. Upgrade: This is another aspect where Oracle has really provided quite good (if not optimal) functionality for customers who wish to migrate to 12c (details in official guide). I (me and my team) personally have migrated 2 projects using this upgrade tool from 11g to 12c and it was good if you use it only once. After upgrade, needs few tweaks here and there with your template code which uses some deprecated API and custom functionalities. If you want upgrade in concurrent fashion then there is this another tool: DataDiff migration tool which can migrate the content after certain dates, thus allowing to migrate content in chunks whenever needed. We faced many issues with DataDiff tool and had to resolve most of the issues by ourselves but that I guess is nothing new who have already worked with product :)
  9. Last but not least, given that now WCS 12c ships with more new and newer features from time to time, it is easy for WCS editors to curate their content as technology demands. I will write more blogs about the new features in future and will keep you updated with latest changes of WCS 12c.
Thanks for reading ! Stay tuned. Need help? Click here.