Node.js - 迁移htaccess.php文件内容

时间:2016-07-08 12:58:26

标签: node.js .htaccess

我正在将网站从PHP迁移到Node.js.在这个PHP站点中,我有一个.htaccess文件。那个文件看起来像这样:

htaccess.php

<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
  mod_gzip_item_exclude mime ^image/.* 
  mod_gzip_item_include handler ^cgi-script$
</ifModule>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>

我不确定如何将这些设置迁移到我的Node.js应用。我的应用是使用Feathers.js构建的。其中,建立在Express之上。不过,我还不确定如何将这些缓存设置添加到我的应用中。当我的应用程序启动时,我正在运行以下内容,这是相当模板的Feathers.js代码:

app.use(compress())
  .options('*', cors())
  .use(cors())
  .use(favicon( path.join(app.get('public'), 'favicon.ico') ))
  .use(bodyParser.json())
  .use(bodyParser.urlencoded({ extended: true }))
  .configure(routes)    
  .configure(hooks())
  .configure(rest())
  .configure(socketio())
  .configure(services)
  .configure(middleware)

然而,我不确定如何将htaccess.php文件中的过期设置集成到我的Node.js应用程序中。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:1)

如果我理解你的问题,你会需要这样的东西。

Function engArray(rigStck As Variant) As Variant
    'CREATE ENGINE ARRAY WITH #, USAGE DAYS AND USED?
    If rigStck <> 0 Then
        ReDim engArray(1 To rigStck, 2)
        For n = 1 To UBound(engArray)
            'engine numbering
            engArray(n, 0) = n
            'reset engine usage to 0
            engArray(n, 1) = 0
            engArray(n, 2) = 0
        Next
    Else
        engArray(1, 0) = 0
    End If
End Function

您还可以查看此https://www.npmjs.com/package/static-expiry