Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can you add a feature ? #4

Open
Bian-Sh opened this issue Aug 8, 2023 · 5 comments
Open

can you add a feature ? #4

Bian-Sh opened this issue Aug 8, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@Bian-Sh
Copy link

Bian-Sh commented Aug 8, 2023

could you pls add a feature for auto overwrite cached image by check response-header :If-Modified-Since .
chat with me if you dont understand wht i say.

reference : https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since

@IvanMurzak IvanMurzak added the enhancement New feature or request label Aug 9, 2023
@IvanMurzak
Copy link
Owner

It makes sense, need to investigate how better to make it. Current problem which I see that is DownloadHandlerTexture is not able to handle that, there is literally no API by Unity. Looks like to implement this feature need to download a raw image in another way and then create Texture2D from the bytes array.

@IvanMurzak
Copy link
Owner

Another problem that could be resolved separately is the delay in loading already cached images. But that is a solution to add an optional argument at the loading function, that will allow a user to choose the loading option (with/without verification)

@Bian-Sh
Copy link
Author

Bian-Sh commented Aug 10, 2023

UnityWebRequest has a Head Function which can set head request , the add header "Last-Modified" to get modified date.
for example

using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

public class LastModified : MonoBehaviour
{
    public string url = "https://example.com"; 

    IEnumerator Start()
    {
        using (UnityWebRequest request = UnityWebRequest.Head(url))
        {
            yield return request.SendWebRequest();

            if (request.result == UnityWebRequest.Result.Success)
            {
                string lastModified = request.GetResponseHeader("Last-Modified");
                Debug.Log("Last-Modified: " + lastModified);
            }
            else
            {
                Debug.LogError(request.error);
            }
        }
    }
}

I have no idea if this could make scene, i ask newbing ,but its worth to have a try.

@IvanMurzak
Copy link
Owner

I don't see how to make it right.
@Bian-Sh You can implement it and create a pull request in this repository.

@Bian-Sh
Copy link
Author

Bian-Sh commented Aug 17, 2023

I don't see how to make it right. @Bian-Sh You can implement it and create a pull request in this repository.

等什么时候我有时间了会去看的,这个功能应该需要服务器API 也支持,我会去做更多的了解,确认这个 if modified 是否可以通过 Head 方法直接请求。

I will take a look when I have time. This feature should require server API support. I will try to understand more and confirm if the "if modified" can be requested directly through the Head method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants