问题原文
原帖链接 · Sr. Schneider · CC BY-SA 4.0
In terms of cache optimization it is recommended for static files like images to cache them forever. In this case if you want to update an image you have to use a different file name so that the client browser downloads the new image instead of showing the cached one.
Situation 1
I don't cache image files. So if I update the file myimage.png the file name remains the same.
Situation 2
I cache image files forever. That's why I use a hash in the file name.
File name before update: myimage.a1b2c3.png
File name after update: myimage.d4e5f6.png
Question
Am I right that file names without hashes are way better in terms of SEO?
已采纳解答
原帖链接 · Kannan · CC BY-SA 4.0
On a long-term basis, I don't think there will be any differences in SEO impact (image-SEO) between the above two methods.
But, there could be short-term SEO impacts when changing filenames during updates.
Google is known to remove non-existent resources from the index after some delay (you can call it a grace period). Whenever you update an image, Google could take some time between de-indexing the old one and indexing the new one.
My suggestion is this:
Maintain filenames (to prevent short term SEO impacts mentioned earlier) with appropriate cache-control headers (for better user experience). You can set the max-age to a reasonable time depending upon a tentative update time in the future and can add must-revalidate directive. By this, whenever an image changes, the browser would pick the latest from the server. Otherwise, guided by max-age, the browser can use the cached copy.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
