Forum

Caching all files with .css .jpg etc. endings in v10?

SolSoCoG
4 December 2015, 15:05
I'm having some issues with caching on prestashop at the new version,
the shopsystem has an insane use of rewrites and it's picture folder is even worse, interleaved as hell.

Previously, I used:
UrlToolkit {
ToolkitID = cache-control
Match ^/.*\.(css|eot|gif|htm|html|ico|jpeg|jpg|js|otf|pdf|png|ps|psd|svg|swf|ttf|txt|woff|woff2)(/|$) Expire 7 days
}
VirtualHost {
[...]
UseToolkit = ref_spam_fix, cache-control, prestashop
[...]
}

And I got all the desired file-endings cached for 7 days.

now at v10 I use:
VirtualHost {
[...]
UseToolkit = ref_spam_fix, prestashop
UseDirectory = static
[...]
}
Directory {
DirectoryID = static
Path = /.*\.(css|eot|gif|htm|html|ico|jpeg|jpg|js|otf|pdf|png|ps|psd|svg|swf|ttf|txt|woff|woff2)(/|$)
ExpirePeriod = 2 weeks
}

and it does nothing, unfortunately.

I also tried setting /img etc. as Path= but as I wrote before it does insane nesting, like /img/p/1/2/3/3/1233-thickbox_default.jpg and I don't think setting path as /img makes it goes recursively through these folders.

Would be neat if I could rebuild the above Expire toolkit as directory settings.

Maybe the result can be used to swap the now obsolete http://dotbalm.org/http-caching-in-hiawatha/ toolkits

Greetings.
David Oliver
4 December 2015, 17:14
I've found that Hiawatha does apply the HTTP caching headers to files in subdirectories.

Path = /images, /imgs, /img


That works for '/img/feature-tour/notes.png'

My image directories are not as nested as yours, being only one or two levels deep. Perhaps there's a subdirectory limit?
SolSoCoG
4 December 2015, 17:30
Ah, okay, so the rewrites I forgot to mention could be the problem?

Stuff like website.net/27670-large_default/twd-mug.jpg is a rewrite from website.net/img/p/2/7/6/7/0/xxyyzz-thickbox_default.jpg .
These rewrites are highly dynamic though.
Hugo Leisink
4 December 2015, 17:57
There is no a subdirectory limit. Hiawatha simply does a match with the Path parameter and the requested URI (taking the length of Path into account). It uses the original request URI, so it ignores rewrites.
SolSoCoG
4 December 2015, 19:06
Thats pretty bad, regex doesn't work on Path aswell, so I'm stranded.

Do I have to do a downgrade then? Is there really no way to achieve *.jpg *.png etc. caching independent from the folder anymore? But I like the new gzip compatibility pretty much, had to do a bash script to gzip cache files regularly.

Or, wait, a nginx proxy for hiawatha to enable caching? Please no .
Hugo Leisink
4 December 2015, 20:03
What if I introduce a new option that allows you to filter for several extensions?
Directory {
DirectoryID = foo
Path = /
Extension = jpg, png
...
}
SolSoCoG
4 December 2015, 22:41
That would be very nice, yes.
Thank you in advance
Hugo Leisink
4 December 2015, 22:49
Ok. It's already implemented and will be available in 10.1.
This topic has been closed.