css query string

前端 未结 2 478
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-20 14:39

Is it possible to pass a query string into a style sheet and if so, can the css process it?

i.e. http://www.domain.com/css/somestyle.css?id=102992992

I notic

相关标签:
2条回答
  • 2021-01-20 14:44

    A query string can be used to ensure that clients don't use old, cached versions of the referenced CSS file rather than retrieving the latest version from the server.

    0 讨论(0)
  • 2021-01-20 15:04

    Yes you can pass a querystring - no a plain CSS file can't use it.

    There are two reasons to do it:

    1. The css file is being dynamically generated
    2. For versioning, to make sure the browser always gets the latest version (the id could be the last-modified timestamp, for example)
    0 讨论(0)
提交回复
热议问题