Search code examples
javacssservletswebserverwebsphere

Server loading static resources too slowly


Server loading static resources too slowly - what server optimizations can I make?

Images + CSS content is loading way too slowly (relatively small files at that) are taking over 1 second each to load. What are some optimizations that I can do server-side to reduce those load times (Other than increasing server processing power/network speed).

The server is WebSphere.


Solution

  • There are plenty possibilies (sorted by importance):

    • Set proper Expires- and Last Modified-Header for all static resources. This can reduce overall requests for static resources dramatically. Thus reducing server load. No requests are the fastest requests with no payload.
    • Serve static resources from a separate cookie-less (sub-)domain.
    • Use CSS-Spites and combine often used graphics like Logos and Icons into one single large image.
    • Combine all your CSS in a single or just a few files. This reduces overall request count and increases frontend performance, too.
    • Optimize your image sizes lossless with tools like PngOut.
    • Pre-gzip your css (and js) files and serve them directly from memory. Do not read them from hard disc and compress on the fly.
    • Use a library like jawr if you do not want to do all these things on your own. Many of these things can jawr handle for you without having negative impacts on your development.
    • Let Apache webserver serve these static contents for you.
    • Use something like mod_proxy that relies on your Caching Headers to serve the contents for you. Apache is faster in serving static resources and more important it can be done from another system in front of your Websphere server.
    • Use a CDN for serving your static content.