When viewing a PDF file in a repository via browser, it appears to be cached and cannot be downloaded properly. #7196

Closed
opened 2025-11-02 07:19:08 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @tcpluess on GitHub (Apr 16, 2021).

Description

Steps to reproduce:

  1. add the first PDF file from the attachments to a repository, and name the file e.g. test.pdf.
  2. commit & push.
  3. in the web UI, navigate to the repository and display the PDF file in the repository. The PDF is nicely displayed.
  4. simulate some changes in the PDF by replacing the existing PDF with the second ond from the attachment. Git marks the PDF file as changed, because there are differences.
  5. commit & push.
  6. in the web UI, navigate to the repository and display the PDF. Expected behaviour: the replaced PDF should be shown (with the changes). Actual behaviour: the browser still loads the old version of the PDF, without the changes.
  7. in the web UI, navigate to the PDF, and select the Raw download. The browser downloads the wrong PDF file with the old contents.
  8. in the web UI, choose "Download Repository". In the downloaded ZIP or TAR file, the correct PDF is included.

Obviously, Gitea (or the web browser) performs some internal caching which leads to the fact that PDF files are not properly updated when they have been changed. Even refreshing the page in the browser does not solve the issue. It can only resolved by using a browser on a different computer, using an "incognito" tab or completely clearing the browser cache. While it is not strictly necessary to have PDF files in Git, it still indicates some problems with caching and the question arises: could this behaviour also affect other files, e.g. plain text files, or source code files or images?

test.pdf
test.pdf

Originally created by @tcpluess on GitHub (Apr 16, 2021). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq) 5. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.14.0 - Git version: git version 2.30.2 - Operating system: alpine-release 3.13.5 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (example URL: https://try.gitea.io/tester125/giteatest2) - [ ] No ## Description Steps to reproduce: 1. add the first PDF file from the attachments to a repository, and name the file e.g. `test.pdf`. 2. commit & push. 3. in the web UI, navigate to the repository and display the PDF file in the repository. The PDF is nicely displayed. 4. simulate some changes in the PDF by replacing the existing PDF with the second ond from the attachment. Git marks the PDF file as changed, because there are differences. 5. commit & push. 6. in the web UI, navigate to the repository and display the PDF. Expected behaviour: the replaced PDF should be shown (with the changes). Actual behaviour: the browser still loads the *old* version of the PDF, without the changes. 7. in the web UI, navigate to the PDF, and select the `Raw` download. The browser downloads the wrong PDF file with the old contents. 8. in the web UI, choose "Download Repository". In the downloaded ZIP or TAR file, the correct PDF is included. Obviously, Gitea (or the web browser) performs some internal caching which leads to the fact that PDF files are not properly updated when they have been changed. Even refreshing the page in the browser does not solve the issue. It can only resolved by using a browser on a different computer, using an "incognito" tab or completely clearing the browser cache. While it is not strictly necessary to have PDF files in Git, it still indicates some problems with caching and the question arises: could this behaviour also affect other files, e.g. plain text files, or source code files or images? [test.pdf](https://github.com/go-gitea/gitea/files/6326442/test1.pdf) [test.pdf](https://github.com/go-gitea/gitea/files/6326443/test2.pdf)
Author
Owner

@KN4CK3R commented on GitHub (Apr 19, 2021):

That should be fixed with #15370.

@KN4CK3R commented on GitHub (Apr 19, 2021): That should be fixed with #15370.
Author
Owner

@dfujim commented on GitHub (Mar 21, 2022):

I have this same issue with firefox but not chrome. If I navigate to view the file via the exact commit, then the pdf renders properly, if not then I see the "cached" version.

Mozilla Firefox 98.0.1
Google Chrome 99.0.4844.82
git version 2.25.1
os CentOS Linux 7
gitea version 1.16.2
database SQLite3

For some reason this does not reproduce in the example above, but when I produce my own version the cached issue persists.

Version 1
Version 2

File link, should show version 2, but shows version 1.

PDFs produced with latex, if that makes a difference

@dfujim commented on GitHub (Mar 21, 2022): I have this same issue with firefox but not chrome. If I navigate to view the file via the exact commit, then the pdf renders properly, if not then I see the "cached" version. Mozilla Firefox 98.0.1 Google Chrome 99.0.4844.82 git version 2.25.1 os CentOS Linux 7 gitea version 1.16.2 database SQLite3 For some reason this does not reproduce in the example above, but when I produce my own version the cached issue persists. [Version 1](https://try.gitea.io/tester126/test/src/commit/2579186df6655f47f71c416ca238514853fd1410/test.pdf) [Version 2](https://try.gitea.io/tester126/test/src/commit/8f6eb9226ba91ad41e31e540ff2ef9ded3615186/test.pdf) [File link](https://try.gitea.io/tester126/test/src/branch/master/test.pdf), should show version 2, but shows version 1. PDFs produced with latex, if that makes a difference
Author
Owner

@wxiaoguang commented on GitHub (Apr 16, 2022):

That should be fixed with #15370.

Close this one.

@wxiaoguang commented on GitHub (Apr 16, 2022): > That should be fixed with #15370. Close this one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7196