简体   繁体   English

LAMP站点上较长的目录路径/名称和URL的不利之处是什么?

[英]What are the downsides of longer directory paths/names and URL's on a LAMP site?

What are the downsides of longer directory paths/names and URL's on a LAMP site? LAMP站点上较长的目录路径/名称和URL的不利之处是什么?

I am trying to organize images on my sites as efficiently as possible, and I'm keen on using many nested directories so that no sub-directory has more than 1,000 sub-directories. 我试图尽可能高效地组织站点上的图像,并且我热衷于使用许多嵌套目录,以使子目录中的子目录都不超过1,000个。

In a worst-case scenario, images would be stored looking something like this: 在最坏的情况下,图像的存储方式如下所示:

./images/76/543/7654321/640/1.jpg

Are there any serious downsides to having so many sub-directories vs. something simpler like this: 拥有如此多的子目录与类似这样的更简单的东西有什么严重的不利之处:

./i/a7/c3/5e.jpg

I suppose the more sub-directories the Server has to dig in to, the longer it's going to take, and the longer the directory structure is, the longer the URL will be, so the more space the HREF will take up in the HTML doc. 我想服务器必须挖掘的子目录越多,占用的时间就越长,目录结构越长,URL就会越长,因此HREF在HTML文档中将占用更多的空间。 。 But how much of a difference will that make? 但是,这会有什么不同呢? Let's say we scale up to millions of users, is this something I need to take into consideration (short dir structure vs long dir structrue)? 假设我们可以扩展到数百万个用户,这是我需要考虑的问题(短目录结构还是长目录结构)?

For context, please view this . 对于上下文,请查看

Thanks! 谢谢!

Having a large number of files in one directory can make it slow. 一个目录中包含大量文件可能会使速度变慢。 You are right to split it up. 您将其拆分是正确的。 You can however try to reduce the length by using all alphanumeric characters in the path names. 但是,您可以尝试通过在路径名中使用所有字母数字字符来减少长度。

If you were to have: 如果您要:

/images/[a-z0-9]{3}/[a-z0-9]{3}/[a-z0-9]{3}.jpg
/images/abc/def/ghi.jpg

With the above you can store 101559956668416 images. 通过以上操作,您可以存储101559956668416图像。 This seems ridiculous so perhaps something like: 这似乎很荒谬,所以也许是这样的:

/images/[a-z0-9]{2}/[a-z0-9]{2}.jpg
/images/ab/cd.jpg

With the above you can store 1679616 images. 有了以上内容,您可以存储1679616图像。 This is a reasonable number but might not be enough for your needs. 这是一个合理的数字,但可能不足以满足您的需求。 So how about this: 那么呢:

/images/[a-z0-9]{2}/[a-z0-9]{2}/[a-z0-9]{2}.jpg
/images/ab/cd/ef.jpg

This allows for 2176782336 (2 billion) images and each directory will only ever have a maximum of 1296 child files/directories. 这允许2176782336(20亿)个图像,每个目录最多只能有1296个子文件/目录。

Mix in some capital letters and perhaps even some symbols and you can get away with even fewer. 混入一些大写字母,甚至可能是一些符号,您可以获得更少的收益。 Personally I would go with the last option though. 就我个人而言,我会选择最后一个选项。 It seems to be a nice balance. 这似乎是一个不错的平衡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM