Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How can we use the versioning for the images without updating its reference but still don't face browser cache issues

NaziyaP
Level 2
Level 2

Dear All,

How can we update image in DAM so that its versioned file can automatically be referenced in the html.

 

Suppose I have uploaded an Image XYZ.jpg and have given path in html as

<img alt="XYZ image" tabindex="1" class="XYZImage" src=“path_to/XYZ.jpg“/>.
 
Now I want to update this Image with another and I want that I only update the image in the DAM like XYZ.jpg-v-2 and my html automatically refers to the new version without any code change so that no browser cache issue come.


Please note, browser cache cannot be disabled at server, its necessary to keep that

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution
Umesh_Thakur
Correct answer by
Community Advisor
Community Advisor
0 Replies
praveenjain
Level 4
Level 4

I dont think this scenario is possible.

Referred Image name should match the name of Image present in DAM.

- Praveen

kunal23
Level 10
Level 10

You can set caching headers appropriately in apache to invalidate the browser cache after the time to live (max-age) value expires. However, It is not good for page performance to set low TTL values for browser cache. 

 

<LocationMatch "^\.*.(jpeg|jpg)$">
     Header set Cache-Control "max-age=222"
     Header set Age 0
 </LocationMatch>

 

Ankur_Khare
Community Advisor
Community Advisor

You need to write a custom workflow which will update the node where image is authored whenever there is update in dam.

Vaibhavi_Gowda
Community Advisor
Community Advisor

Hi @NaziyaP , 

In this scenario, you need to go for customised solution. 

This cannot be achieved straight forward since image name differs aem stores the copy of image and doesn't replace the same. 

<img src=" ${dynamic path}" />

So steps would be, 

  • Write a service to fetch the image under /content/dam/path to image. 
  • Get the latest image by created/lastmodified date. Or you can sort using version numbers too. 
  • Update the image src with dynamic path
Umesh_Thakur
Community Advisor
Community Advisor

Hi @NaziyaP,

we have One option available OOB, "Move" you can achieve this.

With Move option you can rename the image and it will update the reference as well without any issue but it will ask you to update the location of image, that might not be the case in your scenario.

This will help you to handle the scenario without any code change.

One more ooption you have that is ACS Named Transformed Image Servlet.

 

Hope this will help.

Umesh Thakur

 

NaziyaP
Level 2
Level 2
Thank You @Umesh_Thakur Will definitely try the solution and post here if it works for me
Umesh_Thakur
Correct answer by
Community Advisor
Community Advisor