Skip to content

[FEATURE] General cache location for stadium image in Area Sizer #2440#2457

Open
sgcr wants to merge 2 commits into
ho-dev:masterfrom
sgcr:feature/stadium-image-cache
Open

[FEATURE] General cache location for stadium image in Area Sizer #2440#2457
sgcr wants to merge 2 commits into
ho-dev:masterfrom
sgcr:feature/stadium-image-cache

Conversation

@sgcr

@sgcr sgcr commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator
  1. changes proposed in this pull request:
  1. src/main/resources/release_notes.md ...
  • has been updated

@sgcr sgcr self-assigned this Jun 22, 2026
@sgcr
sgcr force-pushed the feature/stadium-image-cache branch from b5917cc to c696ee5 Compare June 23, 2026 05:28
@sgcr
sgcr force-pushed the feature/stadium-image-cache branch from c696ee5 to a39b4d5 Compare June 23, 2026 05:45
@sgcr
sgcr requested a review from wsbrenk June 23, 2026 05:45
@sgcr
sgcr marked this pull request as ready for review June 23, 2026 05:45
@sgcr sgcr linked an issue Jun 23, 2026 that may be closed by this pull request
@wsbrenk

wsbrenk commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

` [Debug] CachedUrlImageProvider: Image could not be loaded from URL 'https://res.hattrick.org/arenas/13/124/1239/1238716/custom-220-100.jpg': https://res.hattrick.org/arenas/13/124/1239/1238716/custom-220-100.jpg

[Debug] CachedUrlImageProvider: Saved image (format 'PNG') to file 'C:\Users\wolfg\Documents\HO\img\stadiumImages\2f0598f59db03c179b1fa13a88b94ca4bc08ceb2119f20e0914ebf532a3d3d33.png'.
`

2nd start of arena sizer gives this logs:

` [Debug] CachedUrlImageProvider: Image could not be loaded from URL 'https://res.hattrick.org/arenas/13/124/1239/1238716/custom-220-100.jpg': https://res.hattrick.org/arenas/13/124/1239/1238716/custom-220-100.jpg

[Debug] CachedUrlImageProvider: Image loaded from file 'C:\Users\wolfg\Documents\HO\img\stadiumImages\2f0598f59db03c179b1fa13a88b94ca4bc08ceb2119f20e0914ebf532a3d3d33.png'.
`

These logs confuse me a bit: Why is it being reported that a load isn't working, even though an image is being saved? Why is the download being done again on the second try, even though there's an image in the cache?

@sgcr

sgcr commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

age could not be loaded from UR

Well, there is a primary image URL and a fallback image URL:
Your club has no custom stadium image.
In that case, the primary image URL is therefore pointing to hyperspace (HTTP code 404 for file not found is returned and that is the reason for the "Image could not be loaded from URL" message).

The fallback image URL can be loaded and can be saved to a file and is therefore cached the next time.

When the dialog is opened the second time, the primary image URL is looked up in the cache first and cannot be found.
That's true because the image was not saved due to "404 - file not found".
The message in that case appears again that the image could not be loaded from the primary URL.

Afterwards the fallback URL should be read from the file cache.

Proposal:
In case of FileNotFoundException there will be no log call anymore (this should be the fix for that).

But in that case the URL is still read and 404 is returned until you design your custom stadium image.

@sgcr sgcr added the effort: low Low efforts expected label Jun 24, 2026
@wsbrenk

wsbrenk commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

But in that case the URL is still read and 404 is returned until you design your custom stadium image.

I think, most of the HO users don't have custom stadium images. I would prefer if the cached image file is available, it should be used.

The players' avatars are presented as buttons, which can be used to download the avatars on user request. What do you think about the same solution for the stadium images?

@sgcr

sgcr commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

But in that case the URL is still read and 404 is returned until you design your custom stadium image.

I think, most of the HO users don't have custom stadium images. I would prefer if the cached image file is available, it should be used.

The players' avatars are presented as buttons, which can be used to download the avatars on user request. What do you think about the same solution for the stadium images?

I agree that if a cached image is available, it should be used.
I also agree that repeatedly requesting the primary URL and receiving 404 is not ideal, even though the actual traffic caused by a 404 response should be very small.

If we want to avoid these repeated 404 requests, I think the clean solution would be to cache the missing primary image state as well.
For example, if the primary stadium image URL returns 404, we could store a small marker for that URL and skip the primary request while this marker is valid.

However, I would not cache this state forever.
Otherwise, if a user creates a custom stadium image later, HO would never pick it up unless the user manually refreshes it.

So I would suggest combining both ideas:

  • use cached images if available
  • cache a 404 result for the primary image as a small marker
  • use a fixed TTL for cached images and not-found markers
  • after the TTL expires, try to refresh automatically
  • if the refresh fails, continue using the existing cached image
  • allow manual refresh by clicking the stadium image

This avoids repeated 404 requests, avoids permanently stale cache entries, and should still keep the traffic very low because the image is only requested when the Arena Sizer is opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort: low Low efforts expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] General cache location for stadium image in Area Sizer

2 participants