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

Use dclone on cache_control #1

Closed
SineSwiper opened this issue Jul 7, 2013 · 3 comments
Closed

Use dclone on cache_control #1

SineSwiper opened this issue Jul 7, 2013 · 3 comments

Comments

@SineSwiper
Copy link

_determine_cache_control is grabbing the cache_control variable and then stuffing a max-age item in there. Since cache_control is an arrayref, the original default is tainted with an ever-growing set of duplicate max-age items.

The cache_control default needs to be cloned prior to modification.

@ido50
Copy link
Owner

ido50 commented Jul 21, 2013

I'm having trouble seeing this happening. Does this happen for requests to the same file? Different files? Files of the same type? When there's a global default? When there's an extension specific default?

I've ran a ton of tests and can't seem to recreate this bug. I need more info, or some kind of an example.

@SineSwiper
Copy link
Author

It's right there in the code:

$cache_control = $self->defaults->{cache_control}
    if $self->defaults && defined $self->defaults->{cache_control};
    # ...
    $cache_control = $self->types->{$ext}->{cache_control}
        if $self->types && $self->types->{$ext} && defined $self->types->{$ext}->{cache_control};
    # ...
unshift(@$cache_control, 'max-age='.$valid_for)
    if $cache;

$self->defaults->{cache_control} is an array ref, which you define as $cache_control. Same thing for $self->types->{$ext}->{cache_control}. In either case, you then unshift the array ref with a "max-age" param. This is the single reference to the default cache_control, not a copy.

I really don't know how to explain it any further without insulting your intelligence.

@ido50
Copy link
Owner

ido50 commented Jul 24, 2013

I saw the problem in the code, realized it's wrong, but for some reason the tests did not display that behavior, though I might be missing something.

Anyway, bug fixed in new version (will release later today), thanks for reporting.

@ido50 ido50 closed this as completed Jul 24, 2013
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

2 participants