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

isNoMediaCache in processBinaryComponent of GraphQLStaticContentResolver #127

Open
EBroersen opened this issue Apr 30, 2020 · 2 comments
Open

Comments

@EBroersen
Copy link

EBroersen commented Apr 30, 2020

We were wondering whether the code for checking isNoMediaCache might be incorrect.

        if (!requestDto.isNoMediaCache()) {
            log.debug("File cannot be cached: {}", file.getAbsolutePath());
            binaryComponent.setLastPublishDate(new DateTime().toString());
        }

We always get a 200 ok for an image request and never receive a 304 on an image. We found out the a new Date is always passed as lastModifiedDate in the browser which led us to this code.
We were wondering if the ! should be presented here.

Regards Erwin Broersen

@alebastrov
Copy link
Contributor

Look like this double negation matters.

@koteswar-k
Copy link

koteswar-k commented May 6, 2021

Hi @alebastrov

StaticContentRequestDto requestDto = StaticContentRequestDto.builder(path, localizationId).localizationPath(localizationPath).baseUrl(this.webRequestContext.getBaseUrl()).noMediaCache(!essentialConfiguration && this.webRequestContext.isSessionPreview()).build();

or

private boolean isNoMediaCache(String path, String localizationPath) {
return !FileUtils.isEssentialConfiguration(path, localizationPath) && this.webRequestContext.isSessionPreview();
}

The above code always return false because of && this.webRequestContext.isSessionPreview() on live environment.
so !requestDto.isNoMediaCache() become true and it always set last publish date for binary component.

As per our analysis, double negation is not required. or are we missing something?

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

No branches or pull requests

3 participants