cancel
Showing results for 
Search instead for 
Did you mean: 

How can media queries be cached more effectively with Varnish ?

Former Member
0 Kudos
  • We are using hybris 5.2.0 in cluster mode, we are using Varnish to cache content delivered over HTTP.

  • After applying the hybris security patch, we have noticed in our production system that most queries sent to the database are queries for media recorded in the server access log. The media url is now like this : GET /media /?context=bWFzdGVyfDIzMFd4MjMwSHw5OTY5fGdlL... We have roughly 100 media queries per second, at peak times that number is much higher.

  • It looks like the media query caching is pretty ineffective, and it seems that Varnish cannot easly cache those URLs. Is the he context parameter of the media URLs make them variables ? This mean that my media url should appear without the context token? Can "pretty url" solve the problem ?

Any idea or configuration to fix this ? Thanks for advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The context parameter value is a constant for a particular media. It is Base64 encoded string containing information about tenant, media folder, size, mime, location in storage and hash of location, thus it cannot change. In latest version of hybris platform this URL looks little bit different - it contains file name also visible in the URL to satisfy SEO - so it looks similar to that

http://domain.com/medias/file.jpg?context=bWFzdGVyfDI

I'm not sure what is your problem exactly, but from what I understood your Varnish cache system is trying to cache those URLs as mad. Maybe you have upgraded from previous version of hybris in which URLs have looked completely different and Varnish must cache them from the scratch?

Answers (3)

Answers (3)

Former Member
0 Kudos

Serving content out of apache is indeed the way forward, using Tomcat for that in a production environment is asking for trouble. Follow your INFRA team advice.

christoph_meyer
Active Participant
0 Kudos

"prettyURL" is indeed the way to go if you want to serve medias via webserver. If your varnish config needs proper urls, this is the way to go for you.

Unfortunately prettyURL is now called "legacy", so there is the chance it will be removed, killing website performance big time.

Former Member
0 Kudos

Indeed - prettyURL is marked as "legacy", but you always have in your hand MediaURLStrategy interface which you can implement as you want so you can craft your very own URL. Currently our media storage is really elastic.

Former Member
0 Kudos

Hi,

  • When medias urls are generated and do not point to a physical file, there is a media web application running on hybris that will interpret the URL and find the real file.That's the reason why hybris medias need be served by Tomcat.

  • Recommendation INFRA :Serve static web content from Apache, using the PrettyURL feature provided by hybris 5.x.This option allows to use medias urls that point to a physical file. With prettyURL disabled --> There could be a performance penalty. With prettyURL enabled, an example URL looks like this:/medias/sys_master/(folder)/h78/hd0/8796125986846.jpg.