开发者

updating an image with same name

I am using Git.

I have changed what an image looks like and saved it out as the same name as what was previously there. I replaced the image in my directory. I can see the image thumbnail has changed and when I open it is the new image. However, when I view the site it still shows the old image. When I ran gitk --all it said there was a diff. I have committed it and did a git add thinking that would fix it. I have obviously cleared my cache many times. Another person who fetched from me has the exact same issue. They 开发者_如何学Gosee the new image in their directory but the old image is being displayed in the web browser.

How do I fix this?


You can try to append "?timestamp" to the src attribute of the img tag.

Example:

<image src="some_image.jpg?123456789" />

You have to use server-side logic to get the File modification time (File mtime) and convert that to seconds since last Unix epoch.

Another option is to use versions instead of timestamps.

Examples:

  • first revision

    <image src="some_image.jpg?v=1" />
    
  • second revision

    <image src="some_image.jpg?v=2" />
    


What you see in the directory / working copy is what you should see on your web browser. Git will not do some magic and make your site serve a older version of the image.

You haven't provided the info on how your site is actually deployed. Is is a local deploy where you are just having a working directory on your machine and the site is deployed from this? Or you deploy to a remote server from your local directory? Or do you push to a remote server and the site is served from that remote server? If it is the latter, make sure the change in the image is pushed to the server.

When your colleague pulled the changes from you and saw the browser, how are they seeing the site again? Is it being deployed on their box again, or from the server? If it is the latter, of course, the pulling wouldn't have changes the contents on the server right?

Can you answer these questions and add the details to your question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜