Can I use a selector to request a font? | Community
Skip to main content
jkpanera
Level 4
October 6, 2020
Question

Can I use a selector to request a font?

  • October 6, 2020
  • 2 replies
  • 1599 views

Hi guys,

 

We use selectors to "bust caches" on the dispatcher. For example:

 

/content/dam/web-content/homepage/homepage-coffee.jpg.transform/home-hero/image.20200916.jpeg

 

Then when that image gets updated the selector 20200916 updates and the browser requests a new image with the new url.

 

UPDATE: In response to a question: We don't want to clear the cache. We prefer to bust the cache. This way when an asset is updated, the modified date increases and the clients can use that to request a new asset. Then we can set the browser cache time to be unlimited but the new resource will be requested anyway when it is updated. That way, if we update the page, but the font doesn't change, the browser will continue to cache. the font.

 

We'd like to do the same thing for a custom font (yes we have a custom font that we update), but the same selector trick doesn't work.

For example, 

/content/dam/static/fonts/icon-font/icon-font.1234.ttf and /content/dam/static/fonts/icon-font/icon-font.ttf.transform/original/icon-font.20200916.ttf both return a 404.

 

Is there anyway I can make this work?

 

Thanks! 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Level 4
October 8, 2020

Do you have any specific reason for the selector approach? We have many other ways to clear the cache.

 

Could you share the rules written on the disp files for the same?

 

Reference article: https://docs.adobe.com/content/help/en/experience-manager-dispatcher/using/configuring/page-invalidate.html

jkpanera
jkpaneraAuthor
Level 4
October 8, 2020

We don't want to clear the cache. We prefer to bust the cache. This way when an asset is updated, the modified date increases and the clients can use. that to request a new asset. Then we can set the browser cache time to be unlimited but the new resource will be requested anyway. That way, if we update the page, but the font doesn't change, the browser will continue to cache. the font.

Shubham_borole
Community Advisor
Community Advisor
November 16, 2020

Noticed same that use of selector gives a 404. Can you see if using a query parameter ?v=123456 (/content/dam/static/fonts/icon-font/icon-font.1234.ttf and /content/dam/static/fonts/icon-font/icon-font.ttf.transform/original/icon-font.ttf?v=1605545369) works for you? Might need to check any node js capabilities to explore this

jkpanera
jkpaneraAuthor
Level 4
December 1, 2020
A query parameter does not solve the issue as caching in the dispatcher can't be done by query parameter.