Should I create a slug on the fly or store in DB?

后端 未结 4 417
有刺的猬
有刺的猬 2020-12-24 08:33

A slug is part of a URL that describes or titles a page and is usually keyword rich for that page improving SEO. e.g. In this URL PHP/JS - Create thumbnails on the fly or st

4条回答
  •  遥遥无期
    2020-12-24 09:14

    For slug generation I don't think that generation time should be an issue, unless your slug algorithm is insanely complicated! Similarly, storage space won't be an issue.

    I would store the slug in the database for the simple reason that slugs usually form part of a permalink and once a permalink is out in the wild it should be considered immutable. Having the ability to change a slug for published data seems like a bad idea.

提交回复
热议问题