Forum

How to create a Directory

Fred
26 April 2016, 22:10
Hi Hugo

I saw an example to gave on how to use directory here https://www.hiawatha-webserver.org/forum/topic/2127/#10963
what I want to do is similar but i am struging to work out how to set the ExpirePeriod.
This is the toolkit that I am trying to convert to a directory
UrlToolkit {
ToolkitID = tiered-cache-control
Match ^/.*\.(gif|htm|html|jpeg|jpg|png)(\?v=.*|\?ver=.*)?(/|$) Expire 1 weeks
Match ^/.*\.(css|js|svg|swf|ttf|txt)(\?v=.*|\?ver=.*)?(/|$) Expire 2 weeks
Match ^/.*\.(eot|ico|otf|pdf|ps|psd|ttf|woff|woff2)(/|$) Expire 2 months
}

Here is what I have done so far
Directory {
DirectoryID = tiered-cache-control
Extensions = gif, htm, html, jpeg, jpg, png ExpirePeriod 1 weeks
Extensions = css, js, svg, swf, ttf, txt ExpirePeriod 2 weeks
Extensions = eot, ico, otf, pdf, ps, psd ttf, woff, woff2 ExpirePeriod 2 months
}

Could please tell me what path is?
I looked at the manual but I don't find it clear.
Is it the webroot path to my index.php?

Thank you
Hugo Leisink
27 April 2016, 13:49
The path contains the path relative to the webroot of the virtual host for which it is used.
VirtualHost {
...
WebsiteRoot = /var/ww
UseDirectory = test
}

Directory {
DirectoryID = test
Path = /test
...
}

The settings in the Directory section will be used for all files and subdirectories in /var/ww/test.
Fred
27 April 2016, 15:58
Hi Hugo,

Your explanation on the path option is very clear thank you.
What about the code in my directory?
Is it correctly formated?
Directory {
DirectoryID = cache-control
Path = /www/mydomain.com/http_live
Extensions = gif, htm, html, jpeg, jpg, png ExpirePeriod 1 weeks
Extensions = css, js, svg, swf, ttf, txt ExpirePeriod 2 weeks
Extensions = eot, ico, otf, pdf, ps, psd ttf, woff, woff2 ExpirePeriod 2 months
}
Hugo Leisink
27 April 2016, 17:21
Uh, no. Use this:
VirtualHost {
...
UseDirectory = cache-control-1w, cache-control-2w, cache-control-2m
}

Directory {
DirectoryID = cache-control-1w
Path = /www/mydomain.com/http_live
Extensions = gif, htm, html, jpeg, jpg, png
ExpirePeriod 1 week
}

Directory {
DirectoryID = cache-control-2w
Path = /www/mydomain.com/http_live
Extensions = css, js, svg, swf, ttf, txt
ExpirePeriod 2 weeks
}

Directory {
DirectoryID = cache-control-2m
Path = /www/mydomain.com/http_live
Extensions = eot, ico, otf, pdf, ps, psd ttf, woff, woff2
ExpirePeriod 2 months
}
Fred
27 April 2016, 17:35
Cool !

Thank you very Hugo
This topic has been closed.