drbxr86044
2011-08-05 19:04
浏览 90
已采纳

替换gzip文件中的字符串

I plan to gzip and cache html pages in the database. Few parts of the cached page need to be replaced with fresh data when it is served back to user.

Is there away to replace string directly in the gzipped pages without ungzipping them? I am using php

图片转代码服务由CSDN问答提供 功能建议

我打算在数据库中gzip和缓存html页面。 当缓存页面被送回用户时,很少有部分缓存页面需要用新数据替换。

是否可以直接在gzip压缩页面中替换字符串而不解压缩它们? 我正在使用php

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dttnb997315 2011-08-05 19:06
    已采纳

    Is there away to replace string directly in the gzipped pages without ungzipping them?

    Simple question, simple answer: No it's not.

    It's because to modify the original data you need to un-gzip the compressed data first, then modify the uncompressed data and then gzip the whole data again. Gzip always compresses a whole chunk of data, so unless you don't change the whole chunk, you need to uncompress, change and recompress.

    点赞 打赏 评论

相关推荐 更多相似问题